I have an array where I would like to get an item and assign it to a variable using a function. I have the following code:
$scope.var1 = '';
$scope.var1 = '';
$scope.arr = [{
'item1':'test1',
'item2':'test2',
'item3':'test3'
}];
$scope.myFunc = function(){
$scope.var1 = $scope.arr.item1;
$scope.var2 = $scope.arr.item1;
};
But when trying to call the function with ng-click="myFunc()" it does not work. Is this even possible to do? Or do I need to get around this another way?
Thank you in advance for any suggestions
$scope.arr[0].item1.