I am working on a project that pulls a number of questions from a JSON file.
The question formats vary but the issue is caused with a slider question type.
I run a HTTP request to get the JSON data and assign it to a scope called 'questions'. I then in the view repeat the questions and if (in this case) the question type is 'slider' I output the HTML.
The issue is that the slider uses a plugin and a scope variable with options. Because I have no control over the questions I am dynamically creating the scopes:
angular.forEach($scope.questions, function(question) {
$scope[question.definedScopeName] = {
// set up the slider config.
};
});
The JSON question contains a defined name to use for the scope so for this example "sliderOne".
So... in my view I output the slider inside an ng repeat:
<rzslider
class="question__slider"
rz-slider-model="question.definedScopeName.value"
rz-slider-options="question.definedScopeName.options">
</rzslider>
The issue here is that to set the model scope correctly I am using the data from the questions scope and therefore it is a string.
Anyway I can tell Angular that I actually want to set the model to the scope named $scope.'the defined scope name'.
Thanks!