AngularJs练习Demo10 ngInclude

Posted 编程猴子

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了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>

 

以上是关于AngularJs练习Demo10 ngInclude的主要内容,如果未能解决你的问题,请参考以下文章

AngularJs练习Demo2

AngularJs练习Demo19 Resource

AngularJs练习Demo12Provider

AngularJs练习Demo18 Resource

AngularJs练习Demo15自定义服务

AngularJs练习Demo11引入Jquery