Continue discovering angularjs and stucked at changing colors on object, if it true - for ex. green, if false another color. I've tried to realized it but it shows me to all rendered data one color:
rssFeedService.getFeed().then(function (results) {
$scope.feed = results.data;
$scope.feed.forEach(function (checkitem){
if (!checkitem.isRead) {
$scope.read = {
"color": "white",
"background-color": "coral"
}
} else {
$scope.read = {
"color": "white",
"background-color": "green"
}
}
});
}, function (error) {
//alert(error.data.message);
});
Here i'm getting data and with loop i'm set the color.
<div class="col-md-12" ng-repeat="q in feed">
<a href="{{q.link}}">
<h1 ng-click="isReadClick(q.id)" ng-style="read"> {{q.title}}</h1>
</a>
<h4>{{q.body}}</h4>
</div>
I Suppose that this happens because I'm using ng-style and should use ng-class for set static color.
readobject in the javascript, and try to print it in the html (<pre ng-bind="read | json"></pre>). Do they match?rssFeedService? Is this an angular service or a third party library's function ?