"use strict"; angular.module("vocabulary") .component("usStateStandards", { templateUrl: "/js/redesign-angular/standardsAndCorrelations/standards/us-state-standards.html", controller: "UsStateStandardsController" }) .controller("UsStateStandardsController", ["standardsAndCorrelationsService", "$sce", function (standardsAndCorrelationsService, $sce) { var ctrl = this; this.$onInit = init; ctrl.edGateUrl = ""; ctrl.haveEdGateUrl = false; function init(){ standardsAndCorrelationsService.setActiveStandardsCategory('usstate'); ctrl.haveEdGateUrl = false; ctrl.gradeList = standardsAndCorrelationsService.getGradeListForCountry('us'); if(ctrl.gradeList != null){ ctrl.selectedGrade = ctrl.gradeList[0].value; } ctrl.statesList = standardsAndCorrelationsService.getStatesForCountry('us'); if(ctrl.statesList !== null){ ctrl.selectedState = ctrl.statesList[0].value; } } function toggleEdGateDisplayOff(){ ctrl.edGateUrl = ""; ctrl.haveEdGateUrl = false; } ctrl.changeState = function(){ ctrl.stateStandards = standardsAndCorrelationsService.getStandardsListForState(ctrl.selectedState); ctrl.showStandards = ctrl.stateStandards !== null; if(ctrl.showStandards){ ctrl.selectedStandard = ctrl.stateStandards[0].value; } toggleEdGateDisplayOff(); }; ctrl.changeGrade = function(){ toggleEdGateDisplayOff(); }; ctrl.setSelectedState = function(value){ ctrl.selectedState = value; ctrl.changeState(); }; ctrl.updateStandards = function(){ console.log ("selected grade is:" + ctrl.selectedGrade ); console.log("selected state is: " + ctrl.selectedState); var stateValue = ctrl.selectedState; if(ctrl.showStandards){ stateValue = ctrl.selectedStandard; } ctrl.edGateUrl = $sce.trustAsResourceUrl(standardsAndCorrelationsService.getRequestUrl(ctrl.selectedGrade, stateValue, 'LA')); ctrl.haveEdGateUrl = true; } } ]);