Angularjs: Name A Variable Using Another's Variable Value
I'm new to AngularJS and I'm still exploring its possibilities. Currently I'm stuck with this problem: How can I name a variable using another's variable value? For example I have
Solution 1:
It seems like it would be better to use an object to store the data, rather than a bunch of things at the $scope
level...:
$scope.item = {foo: 'Foo', bar: 'Bar'};
// ...
$scope.variable_with_value_foo_or_bar = 'foo';
Then access with:
{{item[variable_with_value_foo_or_bar]}}
Post a Comment for "Angularjs: Name A Variable Using Another's Variable Value"