2
How can I change the Button class?
<!doctype html>
<html ng-app="ui.bootstrap.demo">
<head>
<script src="//ajax.googleapis.com/ajax/libs/angularjs/1.3.13/angular.js"></script>
<script src="//angular-ui.github.io/bootstrap/ui-bootstrap-tpls-0.13.1.js"></script>
<script src="example.js"></script>
<link href="//netdna.bootstrapcdn.com/bootstrap/3.1.1/css/bootstrap.min.css" rel="stylesheet">
</head>
<body>
<div ng-controller="ButtonsCtrl">
<h4>Radio & Uncheckable Radio</h4>
<pre>{{radioModel}}</pre>
<div class="btn-group">
<label class="ng-class: {{BA}}" ng-model="radioModel" btn-radio="'A'">A</label>
<label class="ng-class: {{BB}}" ng-model="radioModel" btn-radio="'B'">B</label>
<label class="{{BC}}" ng-model="radioModel" btn-radio="'C'">C</label>
<label class="{{BD}}" ng-model="radioModel" btn-radio="'D'">D</label>
<label class="{{BE}}" ng-model="radioModel" btn-radio="'E'">E</label>
</div>
</div>
</body>
</html>
angular.module('ui.bootstrap.demo', ['ui.bootstrap']);
angular.module('ui.bootstrap.demo').controller('ButtonsCtrl', function ($scope) {
$scope.singleModel = 1;
$scope.radioModel = '';
$scope.BA = 'btn btn-default';
$scope.BB = 'btn btn-default';
$scope.BC = 'btn btn-default';
$scope.BD = 'btn btn-default';
$scope.BE = 'btn btn-default';
$scope.checkModel = {
A: false,
B: false,
C: false,
D: false,
E: false
};
});
I understood the change. I would like to do something like this: ng-if="{{ radioModel }} == 'A' ? BA = 'btn btn-Primary' : BA = 'btn btn-default'"
– Luis Souza
Or better: ng-if="{{ radioModel }} === 'A' ? ng-class='btn btn-Primary' : ng-class='btn btn-default'"
– Luis Souza
@Luissouza I updated the answer with your example.
– OnoSendai
Worked perfectly!
– Luis Souza
@Luissouza I’m happy to read this!
– OnoSendai
How could I get the data from a Json? By changing the buttons. http://answall.com/questions/77777/repeat-n%C3%A3o-angled
– Luis Souza