Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to use MaterializeCSS in Angular 2

I really want to use materializecss in Angular2.

I followed the steps from

https://www.npmjs.com/package/angular2-materialize.

I'm still studying Angular2 and using angular-cli. But I don't know where to add the plugin bec.

I don't know where webpack is. And I tried to follow this steps too https://medium.com/@ladyleet/using-materializecss-with-your-angular-2-angular-cli-app-2eb64b05a1d2#.cpgjvvo7m

but I don't know where angular-cli-build.js is?

oh, btw I am using angular-cli. I hope there's someone who can help me.

I really like materializecss. I'm always using it when I'm using AngularJS.

Thanks.

like image 654
LordGrim Avatar asked Jan 30 '17 13:01

LordGrim


Video Answer


1 Answers

Answer from this repo : https://github.com/stanleyeosakul/angular-travelville

Setup Materialize CSS

  1. Run yarn add materialize-css@next ( or npm i materialize-css@next)
  2. Add Materialize CSS into .angular-cli.json ( or angular.json)

    json // .angular-cli.json { "apps": [ { ... "styles": [ "../node_modules/materialize-css/dist/css/materialize.min.css", "styles.css" ], "scripts": [ "../node_modules/materialize-css/dist/js/materialize.min.js" ], ... } ] }

  3. Declare the M variable in ./src/typings.d.ts (or create the file yourself)

    typescript declare var M;

  4. Materialize CSS is now integrated into Angular!

like image 72
lokeshrmitra Avatar answered Oct 28 '22 03:10

lokeshrmitra