|
"extractCss": true,
"styles": [
"src/styles.css",
{
"input": "src/app/first/first.css",
"bundleName": "first",
"inject": false
},
{
"input": "src/app/second/second.css",
"bundleName": "second",
"inject": false
}
],
|
|
import { Component, OnInit, Inject } from '@angular/core';
import { DOCUMENT } from '@angular/common';
import { data } from './datasource';
import { PageSettingsModel } from '@syncfusion/ej2-angular-grids';
@Component({
selector: 'app-first',
templateUrl: './first.component.html',
styleUrls: ['./first.component.css']
})
export class FirstComponent implements OnInit {
public data: object[];
public pageSettings: PageSettingsModel;
constructor(@Inject(DOCUMENT) private document: Document) {}
loadStyle(styleName: string) {
const head = this.document.getElementsByTagName('head')[0];
let themeLink = this.document.getElementById(
'client-theme'
) as HTMLLinkElement;
if (themeLink) {
themeLink.rel='nofollow' href = `${styleName}.css`;
} else {
const style = this.document.createElement('link');
style.id = 'client-theme';
style.rel = 'stylesheet';
style.rel='nofollow' href = `${styleName}.css`;
head.appendChild(style);
}
}
ngOnInit(): void {
this.loadStyle('first');
this.data = data;
this.pageSettings = { pageSize: 6 };
}
} |