javascript - Angular.js compile partial view controller -


hi have mvc application, home page , partial view (info.cshtml) in homepage. when add angularjs controller _layout (after: var mymodule = angular.module("mymodule", ["kendo.directives"]);) , have in info.cshtml:

<div id="aaaa" ng-controller="test">{{msg}}</div> <script>     ///!!!!!!!!!!!!!important, not remove!!!!!!!!!!!!!!     var $injector = angular.element($('#aaaa')).injector();     var element = angular.element($('#aaaa'));     $injector.invoke(function ($compile, $timeout) {         var scope = element.scope();         $compile(element)(scope);         $timeout(function () {             scope.$apply();         });     }) </script> 

, ok, when add controller directly info.cshtml breaks "error: [ng:areq] argument 'test' not function, got undefined":

<div id="aaaa" ng-controller="test">{{msg}}</div> <script>     mymodule.controller("test", function ($scope, $http, $timeout) {         alert('here');         $scope.msg = 'dsadsadaddas';     })      ///!!!!!!!!!!!!!important, not remove!!!!!!!!!!!!!!     var $injector = angular.element($('#aaaa')).injector();     var element = angular.element($('#aaaa'));     $injector.invoke(function ($compile, $timeout) {         var scope = element.scope();         $compile(element)(scope);         $timeout(function () {             scope.$apply();         });     }) </script> 


Comments

Popular posts from this blog

python - No exponential form of the z-axis in matplotlib-3D-plots -

php - Best Light server (Linux + Web server + Database) for Raspberry Pi -

c# - "Newtonsoft.Json.JsonSerializationException unable to find constructor to use for types" error when deserializing class -