如果没有 app.module.ts 文件,那么我们如何使用 Angular Material ,因为要使用 Angular Material 首先我们需要导入材质模块,还有其他方法吗?
我尝试将其导入配置文件中,但现在可以了
基本上,Angular v-17 以后的版本默认通过 CLI 独立运行,这意味着当您创建新项目时,它不会包含任何模块。您可以使用 --no-standalone 标志创建一个项目,即新项目 --no-standalone,或者您可以将依赖项导入到组件而不是 app.modules 中,如下面的代码:
import { MatAutocompleteModule } from '@angular/material/autocomplete';
@Component({
standalone:true,
imports: [
MatAutocompleteModule,
],
selector: 'your-component',
templateUrl: './your.component.html',
styleUrls: ['./your.component.scss']
})
希望这有帮助!