问题
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