"use strict"; angular.module("vocabulary") .component("moveToCategoryTree", { templateUrl: "/js/redesign-angular/categories/move-to-category-tree.html", controller: "MoveToCategoryTreeController", bindings:{ categoryId: "<", onMoveToCategory: "&", onCancelMove: "&" } }) .controller("MoveToCategoryTreeController", ["lessonService", function(lessonService) { var ctrl = this; this.$onInit = init; ctrl.showCategoryList = false; ctrl.selectedCategoryId = null; function init() { ctrl.selectedCategoryId = ctrl.categoryId; } ctrl.setSelectedCategory = 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 } }); }; }]);