angularjs - How to load the script section while using externally -


i have attached sample plunker

<html>     <head>       <title>angular js views</title>       <script src = "https://ajax.googleapis.com/ajax/libs/angularjs/1.3.14/angular.min.js"></script>       <script src = "https://ajax.googleapis.com/ajax/libs/angularjs/1.3.14/angular-route.min.js"></script>    </head>     <body>       <h2>angularjs sample application</h2>       <div ng-app = "mainapp">          <p><a href = "#addstudent">add student</a></p>          <p><a href = "#viewstudents">view students</a></p>          <div ng-view></div>           <script type = "text/ng-template" id = "addstudent.htm">             <h2> add student </h2>             {{message}}          </script>           <script type = "text/ng-template" id = "viewstudents.htm">             <h2> view students </h2>             {{message}}          </script>       </div>        <script>          var mainapp = angular.module("mainapp", ['ngroute']);            mainapp.config(['$routeprovider', function($routeprovider) {             $routeprovider.              when('/addstudent', {                templateurl: 'addstudent.htm',                controller: 'addstudentcontroller'             }).              when('/viewstudents', {                templateurl: 'viewstudents.htm',                controller: 'viewstudentscontroller'             }).              otherwise({                redirectto: '/addstudent'             });          }]);          </script>     </body> </html> 

when run application, external sample content loaded layout page. have maintained seaparate js(template.js). while loading script section in angular controller function not hit values not assigned. control rendered without model values. want maintain more 50 js files. here can't refer js file in main page(index.html).

you assigning controller

app.config(function ($routeprovider, $locationprovider) {     $routeprovider         // home page           .when('/', {               templateurl: 'samples/template.html',               controller: "dropdownctrl",           }) .otherwise({         redirectto: '/'     }); }); 

also include template.js file in header try this


Comments

Popular posts from this blog

Spring Boot + JPA + Hibernate: Unable to locate persister -

go - Golang: panic: runtime error: invalid memory address or nil pointer dereference using bufio.Scanner -

c - double free or corruption (fasttop) -