angular之隐藏显示,CSS类和样式

直接上代码

<body ng-app='app'>

<div ng-controller="showHideController">
<button ng-click="show()">按钮</button>
<ul ng-show="isShow" class="color-{{isDis}}">
<li>111</li>
<li>111</li>
<li>111</li>
<li>111</li>
</ul>

</div>

<div ng-controller="cssController">
<div ng-class="{error:isError,warning:isWarning}">{{msgText}}信息</div>
<button ng-click="showError()">error</button>
<button ng-click="showWarn()">waring</button>
</div>

</body>

angular.module('app',[])

.controller('showHideController',function($scope){
$scope.isShow=false;
$scope.isDis=false;
$scope.show = function(){
$scope.isShow=!$scope.isShow
$scope.isDis=!$scope.isDis
}
})
.controller('cssController',function($scope){
$scope.isError=false;
$scope.isWarning = false;
$scope.showError = function(){
$scope.msgText="this is error!!"
$scope.isError=true;
$scope.isWarning = false;
}
$scope.showWarn = function(){
$scope.msgText="this is warn!!"
$scope.isError=false;
$scope.isWarning = true;
}
})

css

 

.color-true{
color: red;
}
.color-false{
color:#000000;
}
.error{
color: red;
}
.warning{
color: yellow;
}

posted @ 2016-04-25 15:17  $button  阅读(1053)  评论(0编辑  收藏  举报