InfomediaLtd / angular2-materialize

Angular 2 support for Materialize CSS framework.
https://infomedialtd.github.io/angular2-materialize/
MIT License
406 stars 139 forks source link

MaterializeCSS 1.0.0-Beta not supported #424

Open don-charlie-pc opened 6 years ago

don-charlie-pc commented 6 years ago

Using materialize-css version 1.0.0 does not work with angular2-materialize. Using the component gives this 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.

Will you add support for materializecss 1.0.0?

Julien-Marcou commented 6 years ago

I believe it is due to the fact that "Materialize" has been renamed to "M" for Meteor packages

Before 1.0.0 it was

// Required for Meteor package, the use of window prevents export by Meteor
(function (window) {
  if (window.Package) {
    Materialize = {};
  } else {
    window.Materialize = {};
  }
})(window);

now it is

// Required for Meteor package, the use of window prevents export by Meteor
(function (window) {
  if (window.Package) {
    M = {};
  } else {
    window.M = {};
  }

  // Check for jQuery
  M.jQueryLoaded = !!window.jQuery;
})(window);

Which means Angular2 Materialize should use

if (!("M" in window)) {
  throw new Error("Couldn't find Materialize object on window. It is created by the materialize-css library. Please import materialize-css before importing angular2-materialize.");
}

instead of

if (!("Materialize" in window)) {
  throw new Error("Couldn't find Materialize object on window. It is created by the materialize-css library. Please import materialize-css before importing angular2-materialize.");
}

It seams to fix some problems, but not all of them :S

Skuriles commented 6 years ago

Can this be added to a PR?

samthomson commented 5 years ago

Any progress on this?