ng-class的使用几种方式
(1):利用双向数据绑定(className根据chang2的值去匹配类)
<div class="{{className}}">............</div>
$scope.className="change2";
(2):通过字符串数组的形式
<div ng-class="{true:'RED',false:'GREEN'}[className]"></div>
$scope.className=true/false;
当className=true的时候,ng-class=RED, or GREEN
(3):通过键值对的形式
<div ng-class="{'A':select1,'B':select2,'C':select3}"></div>
$scope.select3=true;此时的ng-class=C;
ng-style的使用几种方式
1)表达式
ng-style="{'font-size':languageType =='en-us'?'12px':'23px'}"
2)绑定对象
//开户类型下拉框样式 $scope.selectDefaultStyle = { "color": "#38270B!important", "border": "1px solid #e0e0e0", "background": "rgba(224,224,224,.1)", "border-radius": "2px", "outline": "none", "height": "30px", "font-size": "14px", "padding-left": "5px", "width": "120px", "margin-right": "10px", }; <select id="type" ng-model="baseInfo.open_type" ng-options="item.id as item.name for item in openTypeArr" ng-show="isBaseInfoEdit" ng-style="selectDefaultStyle"> </select>