I am facing an issue with scope closure.
... function(scope) {
...
});
Within the scope, I need to achieve the following:
$scope.favoriteTitle = 'some value'
The challenge is that favoriteTitle
cannot be static. It needs to be generated dynamically due to multiple possible <item>Title
.
This is my current approach.
scope[var + 'Title'] = 'some value'
However, this method does not successfully assign the required value to the scope variable.
I have conducted an inspection using batarang inspector
, which confirmed that the variable is not being properly assigned to the scope.
I also tried adding a $watch
on that property, but both oldvalue
and newvalue
remain undefined
.