I want to get styles from API and render the component based on that styles.
import { Component } from '@angular/core';
import { StyleService } from "./style.service";
import { Style } from "./models/style";
@Component({
selector: 'app-root',
templateUrl: './app.component.html',
styles: [``]
})
export class AppComponent {
header: boolean;
footer: boolean;
style: string;
constructor(private styleService: StyleService) {}
ngOnInit() {
this.logStyles()
}
logStyles() {
this.styleService.getStyles({
business: 'sekeh'
})
.subscribe(
(val) => {
this.header = val.header,
this.footer = val.footer,
this.style = val.style
},
response => {
console.log("POST call in error", response);
},
() => {
console.log("The POST observable is now completed.");
});
}
}
I have two questions. do i have access to style property in AppComponent class? so i can push new styles to the array. or can i save the api styles in a variable and set styles property to that variable?