I found one solution for my problem on the internet, but i have a problem that i dont know how to overwrite this:
restrict: 'A',
scope: {
file: '=',
fileName: '='
},
into TypeScript.
I have tried this:
constructor($scope: ng.IScope) {
var directive: ng.IDirective = {};
directive.scope = {
file: '=',
fileName: '='
}
}
But it doesnt help, i still have an error:
The property 'file' does not exist on value of type 'ng.IScope'.
Used this example: http://jsfiddle.net/lsiv568/fsfPe/10/
Maybe (or probably) I am doing something wrong and I have to fix this error in another way, but I hope that you will lead me to the right solution.
ng.IScope doesn't have a 'file'\'filename' property. Simply extend the interface. Something like this:
interface IMyScope extends ng.IScope
{
file: any;
fileName: any;
}
constructor($scope: IMyScope) {
}
EditHere's how I create directives with a scope:
class MyDirective implements ng.IDirective {
public scope: IMyScope;
// bla bla
constructor() {
this.scope = {
file: '=',
fileName: '='
};
}
this.link = (scope: IMyScope, elem: JQuery, attrs) => {
// bla bla
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With