Hello,
I have a view that is displaying elements in an array. I added a directive
to the view that displays a popup window when user clicks the view, user
enters data in popup, clicks 'OK' and a a method 'saveLink()' on
the directive is called.
That method in turn calls a datastore service that adds the object to an
array (there is no db persistence yet).
The object is added to the array - if I add console.log(service.data.links)
_after_ I added to the array, I see the newly added object
Problem is, the view is not updated automatically. That array that when
dumped in the service shows the newly added item does no tshow it in the
view. So it probably is not the same array.
Do I have to manually update the array of links used in the view?
// this is the view:
<ul class="links">
<li class="link" ng-repeat="link in links"
ng-style="{left:link.locX + 'px'}">
<span>
<a ng-ref="link.url" title="{{link.popup}}"><img
src="images/bullet_red.png">{{link.title}}</a>
</span>
</li>
</ul>
// this is the function in the directive that gets called after user clicks
'OK' in popup
scope.saveLink = function(){
dataStore.saveLink({
startYear: scope.link.jaar.min,
endYear: scope.link.jaar.max,
title: scope.link.title,
popup: scope.link.popup,
url: scope.link.url
});
initScopeKeys(['link.jaar.min','link.jaar.max','link.title','link.url','link.popup'])
scope.showEditwindow(false);
}
// This is the dataStore.saveLink() function where data gets added
service.saveLink = function(data){
service.data.links.push(data);
}
So console.log(service.data) shows the newly added item. But $scope.links
is not updated. Should I call the directive that created that link array
and tell it to re-create?
--
You received this message because you are subscribed to the Google Groups
"AngularJS" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/angular.
For more options, visit https://groups.google.com/d/optout.