ng-class

angular ng-class if-else expression

心已入冬 提交于 2019-11-26 15:41:26
I'm using angularjs ng-class at the following way: <div class="bigIcon" data-ng-click="PickUp()" ng-class="{first:'classA', second:'classB', third:'classC', fourth:'classC'}[call.State]"/> and I wondered if I can use if-else expression, can I do something similar to this: <div class="bigIcon" data-ng-click="PickUp()" ng-class="{first:'classA', second:'classB', else:'classC'}[call.State]"/> meaning whenever call.State different from first or second use classC and not specify each value. thanks! Use nested inline if-then statements ( Ternary Operators ) <div ng-class=" ... ? 'class-1' : ( ... ?

How to use ng-class in select with ng-options

风格不统一 提交于 2019-11-26 12:25:19
I have an array of Person objects var persons = [ {Name:'John',Eligible:true}, {Name:'Mark',Eligible:true}, {Name:'Sam',Eligible:false}, {Name:'Edward',Eligible:false}, {Name:'Michael',Eligible:true} ]; and i am using select with ng-options like this: <select ng-model="Blah" ng-options="person.Name for person in persons"></select> I want to show the record with Eligible:false in red color. So the problem is how do i use the ng-class in select inorder to achieve this? Since we are not using any option tag it wont work if i simply add ng-class in the select element itself. You could create a

adding and removing classes in angularJs using ng-click

◇◆丶佛笑我妖孽 提交于 2019-11-26 06:05:15
问题 I am trying to work how to add a class with ngClick. I have uploaded up my code onto plunker Click here. Looking at the angular documentation i can\'t figure out the exact way it should be done. Below is a snippet of my code. Can someone guide me in the right direction <div ng-show=\"isVisible\" ng-class=\"{\'selected\': $index==selectedIndex}\" class=\"block\"></div> Controller var app = angular.module(\"MyApp\", []); app.controller(\"subNavController\", function ($scope){ $scope.toggle =

angular ng-class if-else expression

删除回忆录丶 提交于 2019-11-26 04:32:42
问题 I\'m using angularjs ng-class at the following way: <div class=\"bigIcon\" data-ng-click=\"PickUp()\" ng-class=\"{first:\'classA\', second:\'classB\', third:\'classC\', fourth:\'classC\'}[call.State]\"/> and I wondered if I can use if-else expression, can I do something similar to this: <div class=\"bigIcon\" data-ng-click=\"PickUp()\" ng-class=\"{first:\'classA\', second:\'classB\', else:\'classC\'}[call.State]\"/> meaning whenever call.State different from first or second use classC and not

How to use ng-class in select with ng-options

ぃ、小莉子 提交于 2019-11-26 02:57:51
问题 I have an array of Person objects var persons = [ {Name:\'John\',Eligible:true}, {Name:\'Mark\',Eligible:true}, {Name:\'Sam\',Eligible:false}, {Name:\'Edward\',Eligible:false}, {Name:\'Michael\',Eligible:true} ]; and i am using select with ng-options like this: <select ng-model=\"Blah\" ng-options=\"person.Name for person in persons\"></select> I want to show the record with Eligible:false in red color. So the problem is how do i use the ng-class in select inorder to achieve this? Since we

Adding multiple class using ng-class

烈酒焚心 提交于 2019-11-26 01:28:04
问题 Can we have multiple expression to add multiple ng-class ? for eg. <div ng-class=\"{class1: expressionData1, class2: expressionData2}\"></div> If yes can anyone put up the example to do so. . 回答1: To apply different classes when different expressions evaluate to true : <div ng-class="{class1 : expression1, class2 : expression2}"> Hello World! </div> To apply multiple classes when an expression holds true: <!-- notice expression1 used twice --> <div ng-class="{class1 : expression1, class2 :