export class Component {
constructor(
private _http: HttpClient,
private _elementRef: ElementRef
) {}
ngOnInit() {
const json = '{"--background-color": "black", "--text-color": "red"}';
this._http.get('host')._subscribe(_res => {
for (let [key, value] of Object.entries(
JSON.parse(json)
)) {
this._elementRef.nativeElement.style.setProperty(
key,
value
);
console.log({ key, value });
}
});
}
}
export class LoginPageComponent implements OnInit {
loginForm: FormGroup | undefined; // краткая запись loginForm?: FormGroup;
ngOnInit(): void {
this.loginForm = new FormGroup({
email: new FormControl('', [Validators.required , Validators.email]),
password: new FormControl('', [Validators.required , Validators.minLength(4)]),
});
}
@Component({
selector: 'app-icon',
templateUrl: './icon.component.html',
styleUrls: ['./icon.component.less']
})
export class IconComponent {
constructor(@Attribute('name') public vasya: string) {
console.log(vasya);
}
}