如何解决angular-cli项目中的上述错误
我正在使用引导标签输入用户界面
我的 angular-cli.json 文件
"styles": [
"../node_modules/bootstrap/dist/css/bootstrap.css",
"../node_modules/primeng/resources/themes/omega/theme.css",
"assets/plugins/tags_input/bootstrap-tagsinput.css",
"styles.scss"
],
"scripts": [
"../node_modules/jquery/dist/jquery.js",
"../node_modules/jquery-sparkline/jquery.sparkline.js",
"../src/assets/plugins/tags_input/bootstrap-tagsinput.js"
]
app.controller.ts 文件
import * as $ from 'jquery';
ngAfterViewInit() {
$('.tagsinput').tagsinput({
tagClass: 'label label-primary'
});
}
app.controller.html
<input class="tagsinput form-control" type="text" value="Amsterdam,Washington,Sydney,Beijing,Cairo"/>
我正面临这个错误
ERROR TypeError: __WEBPACK_IMPORTED_MODULE_5_jquery__(...).tagsinput is not a function
at advisorCreateEditComponent.webpackJsonp.../../../../../src/app/advisor/advisor-create-edit.component.ts.advisorCreateEditComponent.ngAfterViewInit (main.bundle.js:104)
at callProviderLifecycles (vendor.bundle.js:169756)
at callElementProvidersLifecycles (vendor.bundle.js:169727)
at callLifecycleHooksChildrenFirst (vendor.bundle.js:169711)
at checkAndUpdateView (vendor.bundle.js:170839)
at callViewAction (vendor.bundle.js:171179)
at execEmbeddedViewsAction (vendor.bundle.js:171137)
at checkAndUpdateView (vendor.bundle.js:170832)
at callViewAction (vendor.bundle.js:171179)
at execComponentViewsAction (vendor.bundle.js:171111)
在 controller.ts 文件中更改
declare var $: any;
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句