首页 > 代码库 > ng-class ionic

ng-class ionic

我发现 ng-class="{yourclass:true,outerclass:false}" 竟然不起作用...囧....

幸好有Google  ....

1 <p ng-class="{{ class }}">First</p>2     <p ng-class="getClass()">Second</p>3     <p ng-class="class">Third</p>4     <p ng-class="{ ‘red‘: true }">Fourth</p>

控制器

1 angular.module(‘app‘, [])2 .controller(‘Ctrl‘, [‘$scope‘, function($scope) {3     $scope.class="red";4     $scope.getClass = function() {5         return $scope.class;6     };7 }]);

CSS

.red {    color: red;}

 

ng-class ionic