Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Angular module doesn't work with AMD #284

Closed
patstuart opened this issue Dec 28, 2017 · 1 comment
Closed

Angular module doesn't work with AMD #284

patstuart opened this issue Dec 28, 2017 · 1 comment
Assignees

Comments

@patstuart
Copy link

If AMD is defined in the browser, the compiled code attaches Cleave to define, not to the window:

//...
else if(typeof define === 'function' && define.amd)
    define([], factory);
//...
else
    root["Cleave"] = factory();

But the Angular plugin incorrectly assumes it is attached to the window in all cases.

$scope.instance = new window.Cleave($element[0], $scope.cleave());

This causes a TypeError.

angular.js:14700 TypeError: window.Cleave is not a constructor
    at Object.pre (cleave-angular.js:1138)
    at angular.js:1385

Fix: The plugin should not assume that Cleave is attached to the window. Instead, it should use the same path as webpackUniversalModuleDefinition uses.

@nosir nosir self-assigned this Mar 14, 2018
@nosir
Copy link
Owner

nosir commented Mar 20, 2018

Fix released in https://github.com/nosir/cleave.js/releases/tag/v1.2.1
Demo: https://github.com/nosir/angular-requirejs-seed (check out master, yarn and bower install), app/index.html

@nosir nosir closed this as completed Mar 20, 2018
@nosir nosir added resolved and removed ongoing... labels Mar 20, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants