"use strict"; angular.module("vocabulary") .component("resourceWords", { templateUrl: "/js/redesign-angular/resourceWords/resource-words.html", controller: "ResourceWordsController", bindings: { data: "<" } }) .controller("ResourceWordsController", ["lessonService", function (lessonService) { var ctrl = this; ctrl.$onInit = function () { if (ctrl.isCMSpremade()){ separateWords(); } }; // todo - rename these ctrl.isCMSpremade = lessonService.isLessonCMSPremade; ctrl.isVazEditorPremade = lessonService.isLessonVazEditorPremade; function separateWords() { ctrl.storyCritical = []; ctrl.academic = []; var storyCriticalIds = ctrl.data.storyCritical.map(function (word) { return word.wordId; }); ctrl.data.topicWords.forEach(function (word) { if(storyCriticalIds.indexOf(word.wordId) >= 0) { ctrl.storyCritical.push(word); } else { ctrl.academic.push(word); } }); } }]);