Is there a way to edit three different variables using just one model? Because in the current approach it looks like just the variable value is being copied to the "editedVar".
<div ng-controller="MyCtrl">
A: {{A}}<br/> B: {{B}} <br/> C: {{C}}<br/>
<input ng-model="editedVar"/>
<br/>
<button ng-click="switchToA()">Switch to A</button>
<button ng-click="switchToB()">Switch to B</button>
<button ng-click="switchToC()">Switch to C</button>
</div>
var myApp = angular.module('myApp',[]);
function MyCtrl($scope) {
$scope.A = 1;
$scope.B = 2;
$scope.C = 3;
$scope.switchToA = function()
{
$scope.editedVar = $scope.A;
};
$scope.switchToB = function()
{
$scope.editedVar = $scope.B;
};
$scope.switchToC = function()
{
$scope.editedVar = $scope.C;
};
}