InfomediaLtd/angular2-materialize

MaterializeCSS 1.0.0-Beta not supported

don-charlie-pc opened this issue ยท 3 comments

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?

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

Can this be added to a PR?

Any progress on this?