Skip to content

Commit 76357e2

Browse files
author
vakrilov
committed
platform filter drictives
1 parent f929a89 commit 76357e2

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
import {Directive, ViewContainerRef, TemplateRef, Inject} from '@angular/core';
2+
import {Device, platformNames} from "platform";
3+
import {DEVICE} from "nativescript-angular/platform-providers";
4+
5+
@Directive({ selector: "[ifAndroid]" })
6+
export class IfAndroidDirective {
7+
constructor( @Inject(DEVICE) device: Device, container: ViewContainerRef, templateRef: TemplateRef<Object>) {
8+
if (device.os === platformNames.android) {
9+
container.createEmbeddedView(templateRef);
10+
}
11+
}
12+
}
13+
14+
@Directive({ selector: "[ifIos]" })
15+
export class IfIosDirective {
16+
constructor( @Inject(DEVICE) device: Device, container: ViewContainerRef, templateRef: TemplateRef<Object>) {
17+
if (device.os === platformNames.ios) {
18+
container.createEmbeddedView(templateRef);
19+
}
20+
}
21+
}

0 commit comments

Comments
 (0)