export class firstController { constructor ($http, $mdDialog, param3, param4) { this.isSaving = false; this._$mdDialog = $mdDialog; this.param3 = param3; this.param4 = param4; this.categories = this.param4.generateCategoriesWithCostForCourse(param3.id, param3.name); }
handleFirstControllerCostChange(category) { if (category.cost_change) { category.adjusted_cost = (category.base_cost || 0) + (category.cost_change || 0); } else { category.adjusted_cost = category.base_cost; category.cost_change_reason = null; } return category; }
save() { //... }}
export class secondController { constructor ($http, $mdDialog, param3, param4, param5) { this.isSaving = false; this._$mdDialog = $mdDialog; this.param3 = param3; this.param4 = param4; this.param5 = param5; this.courseData = this.param3.getCourseDataForNewStudents(this.param4.course_id, this.param5.semester_id); this.courseBaseCost = this.param4.course_category.toUpperCase() == 'FREE' ? 0 : this.courses.base_cost;
this.handleSecondControllerChange(); }
handleSecondControllerCostChange() { if (this.courseData.cost_change) { this.courseData.adjusted_cost = (this.courseBaseCost || 0) + (this.courseData.cost_adjustment || 0); } else { this.courseData.adjusted_cost = this.courseBaseCost; this.courseData.cost_change_reason = null; } save() { //... } }
// PLEASE READ BELOW COMMENT /* Commented parameters are from secondController that I was attempting to 'merge' * into firstController to create one controller for both classes */
export class combinedControllersModalController { constructor($http, $mdDialog, param3, param4, param5, param6) { this.isSaving = false; this._$mdDialog = $mdDialog; this.param3 = param3; this.param4 = param4; // this.param5 = param5; // this.param6 = param6; this.categories = this.param4.generateCategoriesWithCostForCourse(param3.id, param3.name); // this.courseData = this.param3.getCourseDataForNewStudents(this.param4.course_id, this.param5.semester_id); // this.courseBaseCost = this.param4.course_category.toUpperCase() == 'FREE' ? 0 : this.courses.base_cost; this.handleSecondControllerChange(); } handleFirstControllerCostChange(category) { if (category.cost_change) { category.adjusted_cost = (category.base_cost || 0) + (category.cost_change || 0); } else { category.adjusted_cost = category.base_cost; category.cost_change_reason = null; } return category; }
handleSecondControllerCostChange() { if (this.courseData.cost_change) { this.courseData.adjusted_cost = (this.courseBaseCost || 0) + (this.courseData.cost_adjustment || 0); } else { this.courseData.adjusted_cost = this.courseBaseCost; this.courseData.cost_change_reason = null; } save() { //... }
cancel() { this._$mdDialog.hide(); } }