Issue
I'm beginner on Angular.js and am having some problems with the directive ng-include
.
I want to display contents of header.html
inside index.html
Well, here's my tree example:
myapp
. public
. . lib
. . . angular.js
. . .
. header.html
. index.html
Header.html code:
<h1>Hello Angular</h1>
Index.html code:
<html ng-app>
<head>
<meta charset="utf-8">
<script src="public/lib/angular.js"></script>
</head>
<body>
<ng-include src="'header.html'"></ng-include>
</body>
</html>
When i run index.html
, i have something like this:
<!-- ngInclude: undefined -->
Solution
Are you accessing the app through a web server or by accessing the file through file://
protocol? In the latter case it won't work due to browser's security restrictions. The solution would be to install Apache or Nginx and access the app through something like http://localhost/myapp/index.html
.
Answered By - Matjaž Drolc
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.