I have been trying to implement function that takes scope variable and changes it's original but with no luck.
var app = angular.module('plunker', []);
app.controller('MainCtrl', function($scope) {
$scope.var1 = 1;
$scope.var2 = 2;
$scope.changeVar = function (varX) {
varX = 'changed';
}
$scope.changeVar1 = function () {
$scope.changeVar($scope.var1);
};
$scope.changeVar2 = function () {
$scope.changeVar($scope.var2);
}
});
To demonstrate what I am trying to achieve I have created this Plunker: http://plnkr.co/edit/kEq8YPJyeAfUzuz4Qiyh?p=preview
What I expect is that either clicking on button1 or button2, var1 or var2 will be changed to 'changed'. Is this even possible?