3

I have this little script and the controller in angular is completely empty so nothing there.

My question is why can't I run to ngIncludes (By the way no errors)?

<!DOCTYPE html>
<html ng-app="demo">
<head>
<meta charset="utf-8" />
<meta name="format-detection" content="telephone=no" />
<!-- WARNING: for iOS 7, remove the width=device-width and height=device-height    attributes. See https://issues.apache.org/jira/browse/CB-4323 -->
<meta name="viewport" content="user-scalable=no, initial-scale=1, maximum-scale=1, minimum-scale=1, width=device-width, height=device-height, target-densitydpi=device-dpi" />
<meta name="msapplication-tap-highlight" content="no" />

<script type="text/javascript" src="bower_components/jquery/dist/jquery.js"></script>
<script type="text/javascript" src="bower_components/angularjs/angular.min.js"></script>
</head>
<body>

<div ng-controller="main">
<ng-include src="'templates/android/header.html'" />
<ng-include src="'templates/android/newsfeed.html'" />
</div>
4
  • 1
    Can start by removing the single quotes on your "src"'s. Commented Aug 9, 2014 at 9:53
  • That would not be a good idea, since that makes sure it is a string in the js parser. Commented Aug 9, 2014 at 9:55
  • Can you reproduce that issue in Fiddle/Planker? Commented Aug 9, 2014 at 9:57
  • And I would try: <div ng-include="templates/android/header.html'"></div> Commented Aug 9, 2014 at 9:58

4 Answers 4

3

I had same problem, but in my case I didn't close the div tag properly:

<div ng-include="'partials/agendar.html'">
<div ng-include="'partials/atendimento.html'">

As I saw you do that, but you're using the 'ng-include' as tag. Try like this (worked perfectly for me). Be sure your angular is updated and then use only 'ng-include' (no 'data-'):

<div ng-include="'partials/agendar.html'"></div>
<div ng-include="'partials/atendimento.html'"></div>

Hope it helps.

Sign up to request clarification or add additional context in comments.

1 Comment

Thanks for this. I had found an example with self-closing div tags like <div ng-include="'path.html'" />, but the second div would not show until I changed them to use separate closing tags: <div ng-include="'path.html'"></div>
0

I prefer valid HTML and suggest you:

<div data-ng-include="'templates/android/header.html'"></div>
<div data-ng-include="'templates/android/newsfeed.html'"></div>

1 Comment

Your example does not return any errors, but only returns the first include and then I am back to scratch. In general my issue is that I can't do more than one include (the next simply doesn't show up). Sorry if I wasn't exactly clear on that.
0

Can you start without src attribute like this:

if you give this type it doesn't show any error messages ngInclude the attribute binding so it doesn't show any error messages.

<data-ng-include="'templates/android/header.html'" />
<data-ng-include="'templates/android/newsfeed.html'" />

The correct way is this:

<div data-ng-include="'templates/android/header.html'"></div>
<div data-ng-include="'templates/android/newsfeed.html'"></div>

6 Comments

I just tried your example and it returned the first include. For the second one the following error: TypeError: Cannot read property 'insertBefore' of null
You don't use src attribute in ngInclude. ngInclude like as src attribute
I just edited my own text, since I did stupid typo's. But It still write that error then.
No it still doesn't work If I am using it with W3 appliant syntax I will get the earlier mentioned error, if not it doesn't return any errors, but in both cases only show the first include.
I done it both the included items will show in my site it doesn't show any errors...
|
0

Actually the question is not so clear for me but I tried like this and it worked correctly:

 <body ng-controller="MainCtrl">
     <div ng-include src='"file1.html"'></div>
     <div ng-include src='"file2.html"'></div>
  </body>

Demo

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.