10

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.

4 Answers 4

7

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!

Sign up to request clarification or add additional context in comments.

1 Comment

Just a little change: instead of ../node_modules use ./node_modules
4

You can import materialize css in your main styles.sass file like this.

// override fonts path to prevent build errors (or use resolve-url loader)
$roboto-font-path: "../node_modules/materialize-css/fonts/roboto/"

// optionally override color variables eg: ...
$primary-color: color("materialize-purple");

@import "~materialize-css/sass/materialize"

Comments

2

Even i tried materialize css with angular-cli project,followed the instructions from MaterializeCss, And it's working. The steps which i followed is:

Install jquery, materialize-css and angular2-materialize

Add jquery and materialize in angular-cli scripts

  "scripts": [
   "../node_modules/jquery/dist/jquery.js",
   "../node_modules/materialize-css/dist/js/materialize.js"
  ]

Add materialize.css in angular-cli

 "styles": [
 "../node_modules/materialize-css/dist/css/materialize.css"
 ]

And finally import MaterializeModule in app.module.ts

 import { MaterializeModule } from 'angular2-materialize';
 @NgModule({
  imports: [
   MaterializeModule
  ]
 })

1 Comment

I would like to ask if all the features of materializecss are working? Thanks btw.
2

Use this npm package and instruction:
Installing & configuring angular2-materialize in projects created with the Angular CLI
https://github.com/InfomediaLtd/angular2-materialize

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.