Created
February 28, 2015 11:43
-
-
Save dustintheweb/167084031750a0b7776d to your computer and use it in GitHub Desktop.
AngularJS: Multiple ternary statements in ng-class
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!doctype html> | |
<html ng-app="myApp"> | |
<head>...</head> | |
<body ng-controller="myController" ng-class="(toggleClass1 ? 'class-1' : '')+' '+(toggleClass2 ? 'class-2' : '')"> | |
<div> | |
stuff... | |
<div class="button1" ng-click="$toggleClass1 = !$toggleClass1"></div> | |
stuff... | |
<div class="button2" ng-click="$toggleClass2 = !$toggleClass2"></div> | |
</div> | |
</body> | |
</html> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(function() { 'use strict'; | |
var app = angular.module('myApp'); | |
// | |
app.controller('mainCtrl',['$scope', function($scope){ | |
$scope.toggleClass1 = false; | |
$scope.toggleClass2 = false; | |
}]); | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment