0

Is it possible to achieve something along the lines of this

var count = 1;

var blah = $scope.someThing_ + count;

So that blah would be equal to

$scope.someThing_1

I feel like this should work, but it does not seem to be working!

Thanks :)

user2085143
  • 4,162
  • 7
  • 39
  • 68
  • $scope.someThing_ is not a string, count is not a string. Why should it work? And more importantly, what are you exactly trying to achieve? – Tarun Dugar Jan 26 '16 at 12:18
  • Possible duplicate of [Setting dynamic scope variables in AngularJs - scope.](http://stackoverflow.com/questions/18875486/setting-dynamic-scope-variables-in-angularjs-scope-some-string) – Max Novich Jan 26 '16 at 12:20

1 Answers1

0

I'm not sure that it is good idea to store data with dynamically created names of variables, but if you really need in it you could work with properties in js also in this way:

$scope["property_name"]

It means that you could save some value with counter like that:

$scope["someThing_" + count] = "value"

Vlad Dekhanov
  • 1,066
  • 1
  • 13
  • 27