You can either implement the Angular2 lifecycle method
`ngOnChanges(changes)`
or make `@Input() mask: string;` a setter
On Tuesday, March 8, 2016 at 10:11:40 PM UTC+1, Olivier Clément wrote:
>
> I have an attribute directive, that has an @Input property of the same
> name as the directive (not that it really matters)
>
> Simplified Code:
> <input [mask]='someBinding'>
>
> @Directive({
> selector: 'mask'
> })
> exportclass MaskDirective implement AfterViewInit {
> @Input() mask: string;
>
> constructor(public el: ElementRef) {};
>
> ngAfterViewInit() {
> $(this.el.nativeElement).mask(this.mask);
> }
> }
>
> Whenever the binding to the [mask] attribute changes, I need to re-apply
> the `mask` to the `nativeElement`
>
> I know I can use `ngOnChanges` but I feel like it wouldn't be very
> efficient?
>
> What is the best way to go around this, in term of best practices?
>
> Thanks
>
> O.
>
>
>
--
You received this message because you are subscribed to the Google Groups
"AngularJS" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/angular.
For more options, visit https://groups.google.com/d/optout.