我想在我的Angular2项目中使用bootstrap-tagsinput库。Angular2:如何正确使用bootstrap-tagsinput
"dependencies": {
...
"bootstrap-tagsinput": "^0.7.1",
...
}
现在我有一个bootstrap-tagsinput
文件夹中node_modules
:该库是用package.json
文件进行安装。我想在特定组件中使用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');
}
}
感谢很多为您的帮助!
我们可以使用ngTagsInput与角2? –