AngularJS Tutorial - ng-include inline template








The following code shows how to use ng-include to include inline template.

Example


<!DOCTYPE html>
<html  ng-app>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.13/angular.js"></script>
</head><!--   w w w  .j  a va2s  .com-->
<body>
  <html ng-app>
    <head>
    <script type="text/ng-template" id="foo.html">
           FOO
    </script>

    <script type="text/ng-template" id="bar.html">
            BAR
    </script>
    </head>
    <body>

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

    </body>
</html>
</body>
</html>

The code above is rendered as follows: