感谢 Nano 的回答对我有帮助。
所以,我在 angular-cli.json 中添加了这样的样式和脚本:
"styles": [
"../node_modules/bootstrap/dist/css/bootstrap.min.css",
"../node_modules/bootstrap-material-design/dist/css/bootstrap-material-design.min.css",
"styles.css"
],
"scripts": [
"../node_modules/jquery/dist/jquery.min.js",
"../node_modules/bootstrap/dist/js/bootstrap.min.js",
"../node_modules/bootstrap-material-design/dist/js/material.min.js"
]
然后,我们必须初始化 bootstrap-material-design。在上下文初始化之后执行此操作很重要。所以,在 ngOnInit() 中对我来说是完美的。我在我的 app.component.ts 中这样做了,如下所示:
import { Component, OnInit } from '@angular/core';
declare let jQuery: any;
@Component({
selector: 'app-root',
templateUrl: './app.component.html',
styleUrls: [ './app.component.css' ]
})
export class AppComponent implements OnInit {
ngOnInit() {
// Init bootstrap-material-design
jQuery.material.init();
}
}
它就像我想要的那样工作。输入正常。