【问题标题】:angular-sweetalert + browserify: how to install/require/inject?angular-sweetalert + browserify:如何安装/需要/注入?
【发布时间】:2017-03-11 17:03:51
【问题描述】:

我通过npm install --save angular-sweetalert 安装了angular-sweetalert ^1.1.2 并尝试注入它:

var app = angular.module('myApp', [
    require('angular-sweetalert') // doesn't work
]);

我收到以下错误

Uncaught Error: [$injector:modulerr] Failed to instantiate module myApp due to:
Error: [$injector:modulerr] Failed to instantiate module undefined due to:
Error: [ng:areq] Argument 'module' is not a function, got undefined

好像是depending on more

  1. 在您的应用中包含文件

    我。 SweetAlert.min.js

    二。 sweet-alert.js 或 sweet-alert.min.js

  2. 在 Angular 中包含模块(即在 app.js 中) - oitozero.ngSweetAlert

任何想法如何正确安装/需要模块?

提前致谢!

【问题讨论】:

    标签: javascript angularjs node.js npm sweetalert


    【解决方案1】:

    模块注入器名称错误,应该是'oitozero.ngSweetAlert'而不是'angular-sweetalert',也不要在模块注入器中使用require。来自angular.module

    模块是服务、指令、控制器的集合, 过滤器和配置信息。 angular.module 用于 配置 $injector。

    var app = angular.module('myApp', [
       'oitozero.ngSweetAlert'
    ]);
    

    PS:确保在注入库模块之前包含所有依赖文件(第 2 步)。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-11-09
      • 2020-09-21
      • 1970-01-01
      • 1970-01-01
      • 2020-11-13
      • 2014-10-24
      相关资源
      最近更新 更多