I have an input text field like this
and my dire
Try this.
import {Directive, SimpleChanges} from '@angular/core';
@Directive({
selector: '[inputTextFilter]'
})
export class MyDirective {
@Input('inputTextFilter') params: string;
constructor(){}
ngOnInit(){
console.log(this.params)
}
}
Try like this in directive :
import {Directive, Input, ElementRef} from 'angular2/core';
@Directive({
selector: '[inputTextFilter]'
})
class FocusDirective {
@Input() inputTextFilter: any;
protected ngOnChanges() {
console.log('inputTextFilter', this.inputTextFilter);
}
}
In the hope that this helps someone else...the problem is in the template.
When I pass the input as [myDirective]="A" the A is being intpreted as an undefined variable. Since I wanted to pass the letter A I should have said [myDirective]="'A'"