I am currently working with AngularJS and TypeScript, and I have encountered an issue with passing a parameter from the view to the controller. In my attempts to solve this problem, I have utilized ng-init as follows:
<div class="col-md-9" ng-controller="MapIZSController" ng-init="init('IZS')">
The goal here is to pass the value of "IZS"
to the controller. The structure of the controller is shown below:
export class MapIZSController
{
static $inject = ["$scope", "leafletData"];
private m_scope: IMapIZSScope;
private m_leafletData;
constructor($scope: IMapIZSScope, leafletData)
{
// Attempt 1
$scope.init = function (type) {
console.log("type is: " + type);
};
// Attempt 2
$scope.init = this.init;
}
public init = (init: any) => {
console.log("init is: " + init)
}
The issue I'm facing is that neither the first nor the second method I tried seems to be working properly.
- The first approach is never executed.
- The second approach also fails to achieve the desired result.
If you have any advice or suggestions on how to resolve this issue, I would greatly appreciate it. Thank you!