Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it possible to use Materializecss without jQuery?

I would like to use materializecss without jQuery. For example, I want to do the following without the use of jQuery:

$('.chips-initial').material_chip({
    data: [{
      tag: 'Apple',
    }, {
      tag: 'Microsoft',
    }, {
      tag: 'Google',
    }],
  });

Thanks

like image 211
rjaraba Avatar asked Feb 20 '17 19:02

rjaraba


1 Answers

Since version 1.0.0 you can.

const elem = document.querySelector('.chips');
const instance = M.Chips.init(elem, options);

List of possible options for the chips.

For Angular2+ you'll need:

npm install materialize-css

In package.json

"dependencies": {
    "materialize-css": "^1.0.0-alpha.4",
}

or later version.

In .angular-cli.json

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

And to be able to use M object in your components, simply add to the imports

declare const M: any;
like image 74
Vadim Aidlin Avatar answered Oct 18 '22 01:10

Vadim Aidlin