So say I have a $scope
variable defined like so:
$scope.data = {
filter: {
state: 'WA',
country: 'US'
}
};
How do I access that in a separate service by string? e.g. data.filter
in the context of the $scope
.
So say I have a service method like so:
function doSomething($scope, variableName) {
// I want to access $scope[variableName] here??
}
I would call it from the controller like so:
service.doSomething($scope, 'data.filter');