Good afternoon,
I have a question concering AngularJS:
In my html-template is a button:
<button class="btn btn-default" ng-click="updateData(testVar)">do it</button>
If the button is clicked, a function is fired which will update the passed $scope variable.
This variable has following structure:
$scope.testVar =
{
id: 1,
name: 'angular',
obj:
{
obj1: 'object1',
obj2: 'object2'
}
};
This is my function for updating the $scope variable:
$scope.updateData = function(param)
{
param = getData();
}
function getData()
{
return {
id: 2,
name: 'test',
obj:
{
obj1: 'object3',
obj2: 'object4'
}
};
}
My Problem is however, after the function is finished, the $scope variable still has the same values as before.
If I update only a property of the variable, it works:
param.name = getData().name;
I don't understand how extactly that works. I would be pleased if someone could explain this process for me.