I want to do something like this in angular how can you do this?
$scope.test = "foo";
$scope.foo = "bar";
and in view
<span>{{scope[test]}}</span> <!-- and return $scope.foo that is "bar" -->
I want to do something like this in angular how can you do this?
$scope.test = "foo";
$scope.foo = "bar";
and in view
<span>{{scope[test]}}</span> <!-- and return $scope.foo that is "bar" -->
It should be with bracket notation:
<span>{{this[test]}}</span>
this
points to current scope object, so with variable test
beeing "foo", the expression will reference $scope.foo
.