Angular 5 with materialize css

﹥>﹥吖頭↗ 提交于 2020-01-05 07:40:11

问题


I'm learning angular 5. but I was following this tutorial to import materialize css module to my app. Ang with angular2materialize then I run ng serve and it compiled successfully. but when I load the content it return an error

Uncaught Error: Couldn't find Materialize object on window. It is created by the materialize-css library. Please import materialize-css before importing angular2-materialize.

how should I proceed?


回答1:


Use import 'materialize-css'; before import {MaterializeModule} from 'angular2-materialize'; in app.module.ts.




回答2:


<!-- Compiled and minified CSS -->
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/materialize/1.0.0-beta/css/materialize.min.css">

<!-- Compiled and minified JavaScript -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/materialize/1.0.0-beta/js/materialize.min.js"></script>

You can use materialize css in 2 ways either by downloading or using CDNs. Add these lines in you app.component.html. These are the links to CDNs. Other versions of CDNs https://cdnjs.com/libraries/materialize



来源:https://stackoverflow.com/questions/49498408/angular-5-with-materialize-css

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!