I want to parameter changes of color of my td so I try this and it's working fine: {{item.name}}
but when I try to use different conditions for example for
item.name : xxx =>color : red
item.name: yyy =>color : yellow
item.name: aaa =>color : blue
try this.
var app = angular.module("app",[]);
app.controller("ctrl" , function($scope){
$scope.items = [{"name":"ali"},{"name":"reza"},{"name":"amir"}];
$scope.getStyle = function(name){
if(name == "ali")
return {'color':'red'};
if(name == "reza")
return {'color':'blue'};
if(name == "amir")
return {'color':'green'};
}
});
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.23/angular.min.js"></script>
<div ng-app="app" ng-controller="ctrl" class="panel-group" id="accordion">
<div ng-repeat="item in items">
<p ng-style ="getStyle(item.name)">{{item.name}}</p>
</div>
</div>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With