After referencing the answer found here:
Upon implementing the $inject syntax, my controller code appears as follows:
class MyCtrl {
public static $inject: string[] = ['$scope'];
constructor($scope){
// implementation
}
}
// register the controller
app.controller("MyCtrl", MyCtrl);
Now, the query arises - what if I need to pass custom arguments in addition to the injected variables into the constructor?:
class MyCtrl {
public static $inject: string[] = ['$scope'];
constructor($scope, customArg){
// implementation
}
}
// How can I successfully provide customArg without errors?
app.controller("MyCtrl", MyCtrl(customArg)); // Incorrect approach
I am under the impression that there might be a fundamental aspect I am overlooking. With this methodology, does every parameter passed into the .controller() function require registration with AngularJS? Should I avoid trying to include custom arguments altogether? Alternatively, is it possible to pass an arbitrary value or object, and if so, how would that be accomplished?