AngularJS extend Controller within controller -


here's issue: want run code of controllerb controllera. issue while variables returned controllera, values requests never returned. here's plunker show issue: http://plnkr.co/edit/gqc9bokti8hxqlf2a2yd?p=preview

var test = $scope.$new(); $controller('ctrl1', {$scope : test});  //the first 2 lines executed, 3d never returns value $scope.variable = test.variable; $scope.varfromfunction = test.varfromfunction(); $scope.varfromrequest = test.varfromrequest; 

the first 2 lines execute, 3d 1 never returns value.

since varfromrequest located inside $timeout method in first controller 500ms, execute 500s later meanwhile angular completes linking phase.

watching varfromrequest in second controller easy solution

 test.$watch('varfromrequest', function(new_value, old){   $scope.varfromrequest = test.varfromrequest;  }) 

here updated plunker http://plnkr.co/edit/tqsjeckrdqekquebcwfx


Comments

Popular posts from this blog

How to connect android app to App engine -

gcc - MinGW's ld cannot perform PE operations on non PE output file -

php - display validation error message next to the textbox in codeigniter -