I have a class
.haba-haba{
border:1px solid red;
height:50%;
width:50%;
}
I am storing the class name in scope variable in my controller using
$scope.className = "haba-haba";
How can I assign $scope.className
to my div
as a class?
I tried doing <div ng-class="'{{className:true}}'"></div>
It didn't work.
Anyone can tell me a solution? thanks in advance!
$scope.className = "haba-haba";
is a good idea. Which class to use is view's concern, not model's concern. You should hard-code the classes in view and based on the conditions to apply classes accordingly. – Khanh TO Feb 28 at 13:41