The desired behavior is that I want to dynamically generate some navigation entries(some <a>s ) based on the data returned from backend. So I bind the herf and the text of each <a> to the fields of an element of an array model. Once the backend call returns, I assign the return data data to model to update the html. model and data share the same structure but this doesn't work for me.
The array looks like
$scope.links = {
'cancelLink': 'http://cancelLink',
'Steps': [{
'label': "Step1",
'link': "http://1"
}, {
'label': "Step2",
'link': "http://2"
}, {
'label': "Step3",
'link': "http://3",
'active': true
}, {
'label': "Review",
'link': "http://review"
}]
};
The updating logic
$scope.loadLinks = function () {
$http({
method: 'GET',
url: '/links'
}).success(function(data) {
$scope.links = data;
});
};
HTML
<li><a class="text clickable" ng-href={{links.Steps[0].link}}>{{links.Steps[0].label}}</a></li>
<li><a class="text clickable" ng-href={{links.Steps[1].link}}>{{links.Steps[1].label}}</a></li>
...
The above code just failed silently without any output from the console. I tried assigning field-wise from date to link (links.Steps[0].link == data.Steps[0].link) and that works. So I wonder is this kind of bulk update not supported or something? Also I wonder how should I troubleshoot this kind of ng-directive issue down the road?