Hi,
I have an AngularJS application as follows. func1 and func2 are triggered
seperately to update the UI. However, the UI updates when I call func1, but
not func2. If I remove the div corresponding to list1 then func2 does
update the UI. Since I'm pretty new to AngularJS, I'm assuming I missed
something pretty obvious. Can anyone help? Thanks!
<html>
....
<body>
<div ng-app>
<div id="divOutput" ng-controller="OutputCtrl">
<div ng-repeat="info in list1">
....
</div>
<div ng-repeat="info in list2">
...
</div>
</div>
</body>
</html>
In the javascript, I have two functions that update the two divs seperately:
function OutputCtrl($scope, $sce) {
$scope.list1 = new Array();
$scope.list2 = new Array();
$(scope).addToList1 = function(item) { $scope.list1.push(item1); }
$(scope).addToList2 = function(item) { $scope.list2.push(item1); }
}
func1()
{
var scope = angular.element($("#divOutput")).scope();
scope.$apply(function(){
scope.addToList1(item);
});
}
func2()
{
var scope = angular.element($("#divOutput")).scope();
scope.$apply(function(){
scope.addToList2(item);
});
}
--
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.