Created
May 7, 2018 16:04
Revisions
-
m-abs created this gist
May 7, 2018 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,26 @@ import { Directive, ElementRef, Input } from '@angular/core'; import { Label } from 'tns-core-modules/ui/label'; /** * Make sure the layout is updated then the Label's text is changed. */ @Directive({ // tslint:disable-next-line:directive-selector selector: 'Label[text]', }) export class UpdateLabelDirective { @Input('text') public set _text(text: string) { const nativeView = this.nativeView; if (nativeView && nativeView instanceof Label) { nativeView.text = text; nativeView.requestLayout(); } } private get nativeView(): Label { return this.el.nativeElement; } constructor(private readonly el: ElementRef) {} }