Reputation: 745
I built buttons with ng-repeat:
<button ng-repeat="alphabet in alpha" ng-click="checkAlpha()" value="{{alphabet}}">{{alphabet}}</button>
$scope.alpha = 'abcdefghijklmnopqrstuvwxyz';
The question is how to remove only the button that is clicked. I used ng-hide in button, but then all the buttons are gone. What is the best way to do that? Thanks
Upvotes: 0
Views: 9409
Reputation: 413
HTML:
<div ng-controller='ctrl'>
<button ng-repeat='alphabet in alpha ' ng-click="checkAlpha($index)" value="{{alphabet}}" id="{{$index}}">{{alphabet}}</button>
</div>
JS:(similar)
angular.module("app", []).controller("ctrl", function ($scope) {
//lets create array from a string.
$scope.alpha = 'abcdefghijklmnopqrstuvwxyz'.split("");
$scope.checkAlpha = function(index) {
$scope.alpha.splice(index, 1);//remove
}
});
FIDDLE:
Upvotes: 3