ng2-bs3-modal,角度为5.2

时间:2018-06-21 21:56:59

标签: angular

有人在Angular 5.2中使用ng2-bs3-modal吗?

我收到“未定义jQuery”错误。

ERROR ReferenceError: jQuery is not defined
at new BsModalService (ng2-bs3-modal.umd.js:35)
at _createClass (core.js:10931)
at _createProviderInstance$1 (core.js:10907)
at resolveNgModuleDep (core.js:10892)
at NgModuleRef_.push../node_modules/@angular/core/esm5/core.js.NgModuleRef_.get (core.js:12129)
at resolveDep (core.js:12619)
at createClass (core.js:12485)
at createDirectiveInstance (core.js:12326)
at createViewNodes (core.js:13784)
at callViewAction (core.js:14218)

我已将以下代码放入app.module.ts

import * as $ from 'jquery';
window["$"] = $;
window["jQuery"] = $;

此后,我得到了另一个错误。

ERROR TypeError: this.$modal.modal is not a function
at BsModalComponent.push../node_modules/ng2-bs3-modal/bundles/ng2-bs3-modal.umd.js.BsModalComponent.init (ng2-bs3-modal.umd.js:263)
at new BsModalComponent (ng2-bs3-modal.umd.js:127)
at createClass (core.js:12485)
at createDirectiveInstance (core.js:12326)
at createViewNodes (core.js:13784)
at callViewAction (core.js:14218)
at execComponentViewsAction (core.js:14127)
at createViewNodes (core.js:13812)
at callViewAction (core.js:14218)
at execComponentViewsAction (core.js:14127)

我正在使用angular-cli。以下是在angular.json文件中加载脚本的顺序(在angular 4.0中为angular-cli.json)

"scripts": [
"node_modules/jquery/dist/jquery.js",
 "node_modules/bootstrap/js/modal.js",
 "node_modules/ng2-bs3-modal/ng2-bs3-modal.js"
]

感谢您的帮助。谢谢。

0 个答案:

没有答案