Код в моей кнопке. Текст}}
Проблема происходит от Ngstyle, если я использую стиль, он работает совершенно нормально. Я прочитал в документации, и здесь, как исправить эту ошибку, чтобы я мог стилизовать с помощью [ngstyle] , но каждое решение было для импорта Commondomodules in app.modules.ts. Поскольку я использую Angular: 17.1.2 У меня нет такого файла.
Код: Выделить всё
import { Component, Input} from '@angular/core';
import { CommonModule } from '@angular/common';
@Component({
selector: 'app-button',
standalone: true,
imports: [],
templateUrl: './button.component.html',
styleUrl: './button.component.css'
})
export class ButtonComponent {
@Input() text!: string;
@Input() color!: string;
}
< /code>
Aapp.component.ts
import { Component } from '@angular/core';
import { RouterOutlet } from '@angular/router';
import { HeaderComponent } from "./components/header/header.component";
@Component({
selector: 'app-root',
standalone: true,
templateUrl: './app.component.html',
styleUrl: './app.component.css',
imports: [RouterOutlet, HeaderComponent]
})
export class AppComponent {
}
Стиль с ngstyle и для работы
Подробнее здесь: https://stackoverflow.com/questions/779 ... -of-button