I am facing a small issue where I am calling a service method within one function and then trying to access the values from that function in another function within the same controller.
However, when attempting to access the values, it shows that they are undefined.
The code below is essentially what I aim to achieve, but not my actual code.
app.controller('Ctrl', function($scope)
{
$scope.a = function() // Function calling service data
{
$scope.value1 = array[]; // Array containing all data called
console.log(value[0].item1); // Value is defined
}
$scope.b = funtion(value1)
{
console.log(value1[0].item1); // Returns undefined
}
)};
In function a, the value is defined, but in function b, it is not. How can I maintain the same value of item1 when accessing it from another function?