I am using Typescript 1.8 + angularjs v.1.5.8
I have a directive that I want to call like this:
<div mi-directiva mi-parametro="ctrl.Objeto"> </div>
My directive is declared as follows:
export class miDirectiva implements ng.IDirective{
restrict:'A';
templateUrl = '/views/template.url';
controller = 'miController';
controllerAs = 'ctrl';
bindToController = true;
scope:{
miParametro:'='
}
constructor(){}
static factory(): ng.IDirectiveFactory {
const directive = () => new miDirectiva();
return directive;
}
}
var app=angular.module('App');
app.directive('miDirectiva',[miDirectiva.factory()]);
My controller is declared this way
export class miController{
miParametro:any;
constructor(scope:any){
var x = scope.miParametro;//undefined
var y = this.miParametro; //undefined
//Como tengo acceso a miParametro?????
}
}
var app=angular.module('App');
app.controller('miController',['$scope', miController]);
Facts:
- myParameter is an object
- According to what I have read, I do not need the $ link or $ compile function, this is not necessary since I am stating that
bindToController=true
and that my Parameter should already be available in the controller - If I receive the object
$attrs
in the controller if I can get the object by$scope.$eval($attrs.miParametro)
but something tells me that this is not done so
How do I access myParameter?