Furthering my project but having a hiccup with databinding.
the change in my data is not getting reflected on the DOM
I've a constructor function inside JS function/object.
constructor: function() {
var self = this;
var navigation = angular.module("navigation", []);
navigation.controller("ProductIDsController", function($scope) {
$scope.productIds = self.productIds;
});
angular.bootstrap(document.getElementById('navigation'), ['navigation']);
}
and product id's are defined on the same level
productIds: ["abc", "xyz", "test"], //DOM gets populated from this array via angular
init: function(productIds) {
console.log(this.productIds); // displays ["abc", "xyz", "test"]
this.productIds.push("another item"); //this didn't work on the dom either
this.productIds = productIds; //I changed the productId's by passing another array
console.log(this.productIds); //the array got changed but DOM is still the same,
}
HTML
<div id="navigation">
<ul data-ng-controller="ProductIDsController">
<li data-ng-repeat="productId in productIds">{{productId}}</li>
</ul>
</div>
Initially the DOM gets populated by the given array, but it's not changing after I pass in another array. how can I have data bind productId's in the given scenario?
Edit: JS Fiddle