angularjs - Script section in angular controller function was not hit also the values are not assigned -


in application want load external html file when click navigation links.
[index.html]

<!doctype html> <html xmlns="http://www.w3.org/1999/xhtml" ng-app="defaultapp"> <head> </head> <body ng-controller="defaultctrl">      <!--dynamic content load external html files-->  </body> </html> 

in app.js file, have defined default routing values controller function external file navigation. [app.js]

            var mainapp = angular.module('defaultapp', ['ngroute']);              mainapp.controller("defaultctrl", ['$scope', '$rootscope','$compile', function ($scope, $rootscope,$compile) {                    $scope.$on('$viewcontentloaded', function (event) {                             $compile($('#sync').contents())($scope);                         });             }])              mainapp.config(['$routeprovider',                      function($routeprovider) {                         $routeprovider.                            when('/addstudent', {                               templateurl: 'sample/addstudent.htm',                               controller: 'addstudentcontroller'                            }).                            otherwise({                               redirectto: '/addstudent'                            });                      }]);                     mainapp.controller("addstudentcontroller", ['$scope', '$rootscope', function ($scope, $rootscope) {                        $rootscope.url = 'sample/addstudent.htm'                    }]) 

in external html files have our controls declaration statements , have script section assign values in controller function.
[addstudent.html]

             <div id="sync">             <div id='sample'>             <p>this sample</p>             </div>              <script>                    mainapp.controller('addstudentcontroller', function($scope) {                         $scope.message = "this page used display add student form";                      });              </script>             </div> 

if run application, external sample content loaded layout page. script section in angular controller function not hit values not assigned. output render without model values. (like output rendered default model values) please suggest solution more needful.

the problem code have defined controller

app.controller("defaultctrl",.. 

change

 mainapp.controller("defaultctrl",.. 

Comments

Popular posts from this blog

magento2 - Magento 2 admin grid add filter to collection -

Android volley - avoid multiple requests of the same kind to the server? -

Combining PHP Registration and Login into one class with multiple functions in one PHP file -