user3705463
user3705463

Reputation: 3

Angularjs ng-include directive not working

I am facing problem while using angularjs ng-include directive.I checked various tutorials,but still couldnt solve.I want to display contents of 'title.html' inside 'index.html'. Contents of 'index.html' :

 <html ng-app>
    <head>
    <script type="text/javascript" src="js/angular.min.js"></script>
    </head>
    <body>
    <h1 ng-model="name">hello {{"name"}}</h1>
    <h3 ng-include="'title.html'"></h3>
    </body>
    </html>

Contents of 'title.html': "sometext"

I am expecting an output like this: hello name sometext

But "sometext" is not displayed.Please help

Upvotes: 0

Views: 193

Answers (1)

Joe
Joe

Reputation: 2596

You don't need test.html inside single quotes. Try this:

  <h3 ng-include="title.html"></h3>

Also, ng-include will not working using the file:/// protocol, so make sure you're using a web server.

Upvotes: 1

Related Questions