I am trying to do simple programming in angularjs. I have created two buttons. The first button has text "clickHere", and the second has no text. My task is when I click the button that has text, it will automatically get empty and the second button will have the same text. (and vice versa).
var myApp = angular.module('myApp',[]);
function MyCtrl($scope) {
$scope.name = 'Superhero';
$scope.name1 = '';
var val = 'Hello';
$scope.click0 = function() {
//alert("hello!");
$scope.name = $scope.name1;
$scope.name1="";
//return val;
};
$scope.click1 = function() {
//alert("hello!");
$scope.name1 = $scope.name;
$scope.name="";
// return val;
};
}
<body ng-app="myApp">
<div ng-controller="MyCtrl">
<button ng-click="click0()" >{{name}}</button>
<button ng-click="click1()" >{{name1}}</button>
</div>
</body>
Here is my code in jsfiddle. http://jsfiddle.net/simpleorchid/a65zV/