I update an array outside application Angular with apply()
function. I notice that for a simple variable it works, but for array the array didn't update. I don't understand why ?
$scope.altLabelFr = [];
if(properties[altLabel]){
$.each(properties[altLabel], function(key,val){
if(val["@language"]=="fr"){
//$scope.altLabelFr.push(val["@value"]);
$scope.altLabelFr.push(val["@value"]);
}
});
console.log($scope.altLabelFr);// results : [1,2,3]
}
for simple variable :
$.each(properties[prefLabel], function(key,val){
if(val["@language"]=="en"){
$scope.prefLabelEn = val["@value"];
}});
in the html template :
{{altLabelFr}} // show [] (supposed to show [1,2,3])
{{prefLabelEn }} // show test
Has someone meet this problem before ? Thank you!
[].forEach()
then you have no dependency. – ste2425 21 hours ago