I'd like to create dynamically controllers responsible for view of data from REST API. My idea is to use ng-repeat directive with data from service and inside it create object with ng-controller directive with parameter from ng-repeat output (The most important condition is that each one question must have its own $scope). Unfortunatelly I don't know how to pass data from service.
AngularJS service code
(function () { 'use strict'; angular .module('App') .factory('questionsDataService', questionsDataService); questionsDataService.$inject = ['$http']; function questionsDataService($http) { return { getMetadata: function (taskId) { var metaData = $http.get('api/toDo/taskVariables/' + taskId).then( function (response) { return response.data; }); return metaData; }, getQuestionsData: function (taskId) { var questionsData = $http.get('api/toDo/getQuestions/' + taskId).then( function (response) { return response.data; }); return questionsData; } } } })();