Ich habe ein paar Tasten, die wie Schalter funktionieren. Wenn Sie auf eins klicken, wird es aktiv und "schaltet" andere Tasten aus. Ich habe dies mit jQuery gemacht, möchte aber AngularJS verwenden. Hier ist mein Code:Wie Klasse hinzufügen und mit AngularJS entfernen?
HTML
<div class="button-bar">
<a class="button button-energized" id="weak">weak</a>
<a class="button button-energized" id="normal">normal</a>
<a class="button button-energized" id="strong">strong</a>
</div>
JavaScript
.controller('AppCtrl', function($scope, $stateParams) {
$('#weak').click(function() {
$('#weak').addClass('active');
$('#normal').removeClass('active');
$('#strong').removeClass('active');
});
$('#normal').click(function() {
$('#normal').addClass('active');
$('#weak').removeClass('active');
$('#strong').removeClass('active');
});
$('#strong').click(function() {
$('#strong').addClass('active');
$('#normal').removeClass('active');
$('#weak').removeClass('active');
});
});
Working Geige http://jsfiddle.net/5DMjt/2221/ –
@soosmca Danke Kumpel für die Geige –