Angular Material Style Class not working

前端 未结 6 1602
后悔当初
后悔当初 2021-01-04 10:57

I\'m using Angular Material to add Date Picker to my app. For some reason the angular material is not applying the original angular materia

6条回答
  •  小鲜肉
    小鲜肉 (楼主)
    2021-01-04 11:10

    This is based on Angular 11. Like everyone said, I did make sure that the style was added to angular.json (which was already there) and the necessary imports in the app.module.ts. Despite these, I was still getting messed up styles. Very interestingly, it did pick up the theme color, but not the control styles. I ended up adding another import in each of the component files where, mat* components were used and it worked fine.

    import { MatButtonModule } from "@angular/material/button";
    

    Remember that when you add that import, your IDE (in my case VS Code and Visual Studio 2019) will tell you (by greying it out) that it's not needed and can be removed.

提交回复
热议问题