gpt4 book ai didi

javascript - Angular -sweetalert + browserify : how to install/require/inject?

转载 作者:行者123 更新时间:2023-12-03 04:49:15 25 4
gpt4 key购买 nike

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

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. include the files in your app

    i. SweetAlert.min.js

    ii. sweet-alert.js OR sweet-alert.min.js

  2. include the module in angular (i.e. in app.js) - oitozero.ngSweetAlert

有什么想法如何正确安装/需要该模块吗?

提前致谢!

最佳答案

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

A module is a collection of services, directives, controllers, filters, and configuration information. angular.module is used to configure the $injector.

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

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

关于javascript - Angular -sweetalert + browserify : how to install/require/inject?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42733270/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com