I want to create the directive for ion-input. For example, this directive append a ‘http://’ prefix to url string, if it’s less. However I don’t understand how get value;
My code:
import {Directive, ElementRef} from '@angular/core';
@Directive({
selector: '[urlFormat]',
host: {
'(blur)': 'onBlur()',
}
})
export class UrlFormatDirective {
constructor(private el: ElementRef) {
}
private onBlur(): void {
console.log('BLUR', this.nativeElement.value); // undefined
}
}
used:
<ion-input type="url" urlFormat></ion-input>