Answer the question
In order to leave comments, you need to log in
Is it possible to change the constructor of a controller depending on different conditions?
Let's say there is a record editing form. This form is called from different places by users with different roles. Depending on the role, after closing the form, some data should change, which for each role is slightly different. I think that it is best to define in the constructor which functions to load, save, change data, and to which place to return after closing.
Now the transition to the post editing form looks something like this:
export class Controller {
constructor($scope: IScope, public $location: ng.ILocationService) {
$scope.edit = this.edit;
}
edit = (id) => {
this.$location.path("/edit/" + id);
}
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question