"use strict"; angular.module("vocabulary") .component("moveToCategory", { templateUrl: "/js/redesign-angular/categories/move-to-category.html", controller: "MoveToCategoryController", bindings:{ categoryId: "<", onMoveToCategory : "&", onCancelMove : "&" } }) .controller("MoveToCategoryController", [ "categoryService", "lessonService", function(categoryService, lessonService){ var ctrl = this; this.$onInit = init; ctrl.categories = null; ctrl.showCategoryList = false; ctrl.selectedCategoryId = null; function init(){ ctrl.selectedCategoryId = ctrl.categoryId; ctrl.categories = categoryService.getCategoryList(); if(ctrl.categories !== null || ctrl.categories !== undefined){ ctrl.showCategoryList = true; } } ctrl.getCategoryList = function(){ return ctrl.categories; }; ctrl.setSelected = function(category){ ctrl.selectedCategoryId = category.categoryId; ctrl.categoryName = category.categoryName; lessonService.chooseCategory(category); }; ctrl.isSelected = function(id){ return id == ctrl.selectedCategoryId; }; ctrl.cancelMove = function(){ ctrl.onCancelMove(); }; ctrl.moveToCategory = function(){ ctrl.onMoveToCategory({ $event: { categoryId: ctrl.selectedCategoryId, categoryName: ctrl.categoryName } }); }; }]);