Skip to content

Instantly share code, notes, and snippets.

@hitenpratap
Created July 22, 2016 07:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hitenpratap/fd321239d3650dba0706f40fa9bdab79 to your computer and use it in GitHub Desktop.
Save hitenpratap/fd321239d3650dba0706f40fa9bdab79 to your computer and use it in GitHub Desktop.
How to use variables with $scope in angularjs
//Lets assume value.questionUniqueId is coming from json response
var dataModel = $parse('data_' + value.questionUniqueId);
var dataModel1 = $parse(value.questionUniqueId + '_data');
var labelsModel = $parse('labels_' + value.questionUniqueId);
var seriesModel = $parse('series_' + value.questionUniqueId);
dataModel.assign($scope, ['1', '2', '3', '4', '5']);
dataModel1.assign($scope, ['1', '2', '3', '4', '5']);
labelsModel.assign($scope, [
[3, 0, 1, 4, 6]
]);
seriesModel.assign($scope, ['Series A']);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment