Rich MacKinnon
Rich MacKinnon

Reputation: 13

Trying to get ng-include working

Learning angular and trying to get a very simple ng-include to work.
tempHeader.html contains a single line of text, which fails to display.

<!DOCTYPE html>
<html ng-app="theApp">
  <head>
    <script src= "http://ajax.googleapis.com/ajax/libs/angularjs/1.2.15/angular.min.js"></script>
  </head>

  <body>
    <ng-include src="tempHeader.html"/>
  </body>
</html>

Upvotes: 0

Views: 44

Answers (1)

tymeJV
tymeJV

Reputation: 104775

ng-include expects a variable, so you have to wrap your string in quotes:

<ng-include src="'tempHeader.html'"/>

Or set a variable and use that:

$scope.url = "tempHeader.html";
<ng-include src="url"/>

Upvotes: 1

Related Questions