I am currently working on a directive that I have created:
feedBackModule.directive("responseCollection", ['deviceDetector', function (deviceDetector) {
return {
restrict: "E",
templateUrl: 'js/modules/Feedback/directives/feedbackResponse/collection.html',
scope: {
collections: '=',
completeCallback: '&'
},
link: function (scope, element, attr) {
scope.endCollection = function () {
scope.completeCallback(scope.collections);
}
}
};
}]);
In order for this directive to work properly, it needs to interact with the following controller:
feedBackModule.controller('FeedbackResponseController', ['$state', 'Query', 'feedbackSkillService', 'feedbackFactory', 'feedbackResponseService', function ($state, Query, SkillFactory, feedbackFactory, feedbackResponseService) {
var num_users = null;
var user_index = 0;
this.activeUser = null;
this.final = false;
this.feedback = feedbackResponseService.getFeedback();
this.completeUser = function (collections) {
this.activeUser.start = false;
if(user_index < (num_users-1)){
user_index++;
this.activeUser = this.feedback.feedback_has_target_users[user_index];
}
else
{
this.final = true;
}
}
}]);
For the HTML part of this functionality, you can use the following code:
<response-collection complete-callback="frCTRL.completeUser()" collections="frCTRL.feedback.feedback_collections" ng-if="frCTRL.activeUser.start && !frCTRL.final"></response-collection>
Although the function works correctly, there is an issue with parsing a variable where it turns out to be undefined
.
My question now is how I can successfully pass a variable or object to a function in this scenario?