Issue
I am very new to Angular.js. In my project, there are two classes named style1 and style2.
The requirement is applying two styles with ng-class
attribute in the template itself. I am not using separate function for this, but a boolean value named 'bool' which is dynamic.
The following are conditions
if (bool) then the style1 & style2 applies
else style1 is applies.
eg:
<input ng-class="something"/>
Each one class value is assigned my cases more than 1 class value is need assign.
How can I put this logic in the ng-class
? I tried so many ways but no use.
Solution
function TodoCtrl($scope) {
$scope.bool = true;
}
.style1 {
color: #f31313;
}
.style2 {
background-color: #baeae6;
}
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.23/angular.min.js"></script>
<div ng-app>
<div ng-controller="TodoCtrl">
<div ng-class="{'style1 style2' : bool, style1 : !bool}">
Hello World!
</div>
</div>
</div>
Answered By - user8317956
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.