I am using AngularJS to load AJAX content and using ng-repeat to create a list of items. On the content I also have {{noun}} as a placeholder. My assumption was that when the ajax content is loaded, AngularJS would automatically replace {{noun}} with the data from $scope.noun model. But it isn't the case. Any quick and dirty way to make it happen?
Here's my code:
AllControllers.controller('AppController', ['$scope', '$http', function ($scope, $http) {
$scope.noun = "My Noun";
$scope.headlines = [{
headline: "Top 10 Tricks to {{noun}}",
usage: 10,
votes: 100
}];
$scope.load_headlines = function() {
$http.get('/data/headlines.json').
success(function(data, status, headers, config){
$scope.headlines = data;
}).
error(function(data, status, headers, config){
console.log(status);
});
};
}]);
<div ng-controller="AppController" ng-init="load_headlines()">
<table>
<tbody ng-repeat="headline in headlines">
<tr>
<td>{{headline.headline}}</td>
<td class="center">{{headline.usage}}</td>
<td class="center">{{headline.votes}}</td>
</tr>
</tbody>
</table>
</div>
headlines_displayedcoming from?load_headlinesmethod and just use the fixed version of$scope.headlines?