AngularJS: $scope NOT updating view from second controller -
i wonder if can help?
i have 1 html file , controller assigned via $routeprovider so
.when('/', { templateurl: 'views/contents.html', controller: 'firstctrl'
everything working fine, had view ng-repeat on object , view updated so
<tbody ng-repeat="item in contents.data"> <tr>
this code working fine, updated item via firstctrl so
$scope.contents = {}; $scope.contents.data = {...}
i have extracted functionality out own controller, still same view, have 1 view , 2 controllers... second controller used specifying ng-controller on tbody so
<tbody ng-controller="secondctrl" ng-repeat="item in contents.data"> <tr>
now know controller working have insert ng-click on , fires the function. updating $scope second controller seems blank..
from documentation states if $scope exists in parent controller (first) child controller overwrites (second) not case, don't have defined in first controller more.
i tried simple test of
$scope.testme = "hi";
and view
{{ testme }}
and nothing ... $scope doesn't exist.
does know whats going on? using correctly?
thanks in advance
if initializing $scope.contents inside of secondctrl experimenting $scope shadowing.
try creating "contents" object inside of firstctrl , when update data. not recreate contents object (i.e. don´t >> $scope.contents = {};
) update data object/array >> $scope.content.data = ...
if doesn´t solve problem, can please provide working fiddle problem. can use 1 starting point http://jsfiddle.net/igorminar/adukg/
Comments
Post a Comment