"use strict"; angular.module("vocabulary") .component("lessonWordsTiered", { templateUrl: "/js/redesign-angular/lessons/lesson-words-tiered.html", controller: "LessonWordsTieredController", bindings:{ topicId: "<", lessonWords : "<" } }) .controller("LessonWordsTieredController", ["topicService", "$filter", "partsOfSpeechService", function(topicService, $filter, partsOfSpeechService){ var ctrl = this; this.$onInit = init; ctrl.tierOneWords = []; ctrl.tierTwoWords = []; ctrl.tierThreeWords = []; function init(){ topicService.getWordsForTopic(ctrl.topicId, null ).then(function (data) { ctrl.tierOneWords = $filter('filter')(data.words, {level: '1'}); ctrl.tierTwoWords = $filter('filter')(data.words, {level: '2'}); ctrl.tierThreeWords = $filter('filter')(data.words, {level: '3'}); }); } ctrl.haveTierOneWords =function(){ return ctrl.tierOneWords.length > 0; }; ctrl.haveTierTwoWords =function(){ return ctrl.tierTwoWords.length > 0; }; ctrl.haveTierThreeWords =function(){ return ctrl.tierThreeWords.length > 0; }; ctrl.haveLessonWords = function(){ return ctrl.lessonWords.length > 0; }; ctrl.isInLesson = function(word){ var retVal = false; var matchWords = $filter('filter')(ctrl.lessonWords, {wordId: word.wordId}); if(matchWords.length > 0){ retVal = true; } return retVal; }; ctrl.abbreviatePartOfSpeech = partsOfSpeechService.abbreviate; ctrl.hasAbbreviationForPartOfSpeech = partsOfSpeechService.hasAbbreviation; } ]);