"use strict"; angular.module("vocabulary") .component("yourLessons", { templateUrl: "/js/redesign-angular/yourLessons/your-lessons.html", controller: "YourLessonsController", bindings: { categoryList: '<' } }) .controller("YourLessonsController", ["categoryService", "$state", "$location", "utilService", "SUPPORT_LESSON_CATEGORY_HIERARCHY", function (categoryService, $state, $location, utilService, SUPPORT_LESSON_CATEGORY_HIERARCHY ) { var ctrl = this; ctrl.showCategoryList = !SUPPORT_LESSON_CATEGORY_HIERARCHY; ctrl.showCategoryTree = SUPPORT_LESSON_CATEGORY_HIERARCHY; ctrl.selectedCategoryId = 0; this.$onInit = init; function init(){ utilService.setTitle("Your Lessons"); //There is no h1 tag } ctrl.getCategoryList = function(){ return ctrl.categoryList; }; ctrl.setSelected = function(categoryId){ ctrl.selectedCategoryId = categoryId; }; ctrl.setSelectedCategory = function(event){ ctrl.setSelected(event.categoryId); }; ctrl.isSelected = function(categoryId){ return ctrl.selectedCategoryId === categoryId }; ctrl.refreshCategoryList = function(){ ctrl.showCategoryList = false; if (!SUPPORT_LESSON_CATEGORY_HIERARCHY) { categoryService.refreshCategoryList().then(function(){ ctrl.categoryList = categoryService.getCategoryList(); ctrl.showCategoryList = true; }); } }; ctrl.refresh = function(){ categoryService.refreshCategoryList().then(function(){ ctrl.categoryList = categoryService.getCategoryList(); $state.go('yourLessons'); }); } }]);