【发布时间】:2016-11-27 19:43:08
【问题描述】:
我正在尝试在我的 Angular2 项目中使用 bootstrap-tagsinput 库。该库是使用package.json 文件安装的:
"dependencies": {
...
"bootstrap-tagsinput": "^0.7.1",
...
}
现在我在node_modules 中有一个bootstrap-tagsinput 文件夹。我想在特定组件中使用 tagsinput。我看到node_modules/bootstrap-tagsinput/dist目录下有一个bootstrap-tagsinput-angular.js文件,但是我无法正常使用。
我是否应该在我的 index.html 中添加 JS 文件,以便 bootstrap-tagsinput 可用于所有组件?或者有没有办法在需要的地方导入它?
另外,有没有办法做这样的事情:
mycomponent.component.html:
<input type="text" value="Amsterdam,Washington,Sydney,Beijing,Cairo" data-role="tagsinput"/>
mycomponent.component.ts:
import {Component, AfterViewInit} from '@angular/core';
import {TagsInputComponents} from 'bootstrap-tagsinput'; // Something like that?!?
@Component({
...
})
export class MyComponentComponent implements AfterViewInit {
ngAfterViewInit():any {
$('input').tagsinput('refresh');
}
}
非常感谢您的帮助!
【问题讨论】:
标签: javascript angularjs angular systemjs bootstrap-tags-input