Q:

How to change the text of button three times in angular? 

Hi Friends here i have done the code for change text of button, like if i press the button the text of the button will change.  But i need the text of the button to be change one more time,
eg: initially "Button1" -->(click)-->"Button2" -->(click)-->"Button3".  
I need button3 also.  
please reffer:http://jsfiddle.net/Ljrpd/17/
var app = angular.module('my-app', [], function () {

})

app.controller('AppController', function ($scope) {
$scope.toggle = true;

$scope.$watch('toggle', function(){
    $scope.toggleText = $scope.toggle ? ' Button1' : 'Button2';
})
})

Some one help me out in this issue. 
Thanks

A:

You don't need toggle variable, you can store selected index as suggested by Peter.  I would also add check for last selection:
app.controller('AppController', function ($scope) {
    $scope.buttonIndex = 0;
    $scope.buttonNames = ['Button 1', 'Button 2', 'Button 3', 'Last Button']
    $scope.changeText = function() {
        if ($scope.buttonIndex === $scope.buttonNames.length - 1) {
            $scope.buttonIndex = 0;
        } else {
            $scope.buttonIndex += 1;
        }
    };
});

JS Fiddle

