angular-sweetalert + browserify:如何install/require/inject?
angular-sweetalert + browserify: how to install/require/inject?
我通过 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
include the files in your app
i. SweetAlert.min.js
ii. sweet-alert.js OR sweet-alert.min.js
include the module in angular (i.e. in app.js) - oitozero.ngSweetAlert
关于如何正确 install/require 模块的任何想法?
提前致谢!
模块注入器名称错误,应该是'oitozero.ngSweetAlert'而不是'angular-sweetalert',也不要在模块注入器中使用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: 确保在注入库模块之前包含所有依赖文件(步骤 2)。
我通过 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
include the files in your app
i. SweetAlert.min.js
ii. sweet-alert.js OR sweet-alert.min.js
include the module in angular (i.e. in app.js) - oitozero.ngSweetAlert
关于如何正确 install/require 模块的任何想法?
提前致谢!
模块注入器名称错误,应该是'oitozero.ngSweetAlert'而不是'angular-sweetalert',也不要在模块注入器中使用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: 确保在注入库模块之前包含所有依赖文件(步骤 2)。