javascript - Angular JS ng-include -


i followed link learn how use: ng-include: http://www.w3schools.com/angular/angular_includes.asp

but have few questions , not understand how works.

if remove app1.js = ng include not works, why? not understand angular trying first time.

app1.js

angular.module('myapp', []).controller('userctrl', function($scope) {  }) 

as if not running code in server not works too, why?

html code:

<script src= "http://ajax.googleapis.com/ajax/libs/angularjs/1.3.14/angular.min.js"></script>   <body ng-app="myapp" ng-controller="userctrl">  <div class="container">   <div ng-include="'includes/content.html'"></div>   <div ng-include="'includes/header.html'"></div> </div>  <script src= "js/app1.js"></script>  </body>  </html> 

you use <body ng-app="myapp" ng-controller="userctrl">

after remove app1.js there no controller match ng-controller there error saying undefined controller (check console),

and change ng-app="myapp" ng-app, if keep ng-app="myapp" search module called myapp angular.module('myapp', [])

remove ng-controller directive , check work.

then whole think be

<body ng-app>... 

Comments

Popular posts from this blog

html - Outlook 2010 Anchor (url/address/link) -

javascript - Why does running this loop 9 times take 100x longer than running it 8 times? -

Getting gateway time-out Rails app with Nginx + Puma running on Digital Ocean -