AngularJs练习Demo10 ngInclude
1 @{ 2 Layout = null; 3 } 4 5 <!DOCTYPE html> 6 7 <html> 8 <head> 9 <meta name="viewport" content="width=device-width" /> 10 <title>ngInclude</title> 11 <script src="~/Scripts/angular.js"></script> 12 13 </head> 14 <body> 15 <div ng-app="myApp"> 16 <script type="text/ng-template" id="tpl.html"> 17 @*AngularJS定义模板必须放在ng-app内*@ 18 Content of the template 19 </script> 20 <script type="text/ng-template" id="tpl2.html"> 21 @*AngularJS定义模板必须放在ng-app内*@ 22 Content of the template2 23 24 </script> 25 <div ng-controller="firstController"> 26 <div ng-include="url"></div> 27 <div ng-include="tpl"></div> 28 <div ng-include src="tpl2"></div> 29 </div> 30 31 </div> 32 33 <script type="text/javascript"> 34 var app = angular.module("myApp", []); 35 app.controller("firstController", function ($scope) { 36 $scope.url = "/Angular/ngInclude1"; 37 $scope.tpl = "tpl.html"; 38 $scope.tpl2 = "tpl2.html"; 39 }); 40 </script> 41 </body> 42 </html>