Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save EddyVerbruggen/cf79273916c9242a9ac26b2714f53479 to your computer and use it in GitHub Desktop.
Save EddyVerbruggen/cf79273916c9242a9ac26b2714f53479 to your computer and use it in GitHub Desktop.
App component specific tablet CSS file in NativeScript
import { Component, OnInit } from "@angular/core";
import { DeviceType } from "ui/enums";
import { device } from "platform";
import { Page } from "ui/page";
@Component({
moduleId: module.id,
selector: "my-component",
templateUrl: "my-component.html",
styleUrls: ["my-component.css"]
})
export class MyComponent implements OnInit {
constructor(private page: Page) {
}
ngOnInit(): void {
if (device.deviceType === DeviceType.Tablet) {
this.page.className = "tablet";
this.page.addCssFile("~/pages/my-component/my-component.tablet.css");
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment