在 Typescript/Angular2 中显示引导框警报?
Show bootbox alert in Typescript/Angular2?
我想在我的 Angular2 项目中使用 Bootbox。我搜索了很多,但没有任何适合我的解决方案。
我也试过 angular2-modal
但是在使用 angular2-modal
时有很多问题,请提出任何好的 doc/Examples/Demos 。
步骤 1: 通过 npm install bootbox --save
安装 bootbox
第 2 步: 如果您使用的是 systemjs,则包括 bootbox,例如:
<script src="node_modules/bootbox/bootbox.js"></script>
第 3 步: 只需在导入所有库之后和组件装饰器之前将 declare var bootbox:any;
放在组件 ts 文件中,然后像 bootbox.alert("Hello world!");
函数调用。
确保您已安装 bootstrap 和 jquery 并包含在索引页中。 jquery 应该排在第一位,然后在 bootstrap 之后。
[编辑]
替代步骤 3
而不是 declare var bootbox:any;
,而是导入类型类型定义:
npm install @types/jquery --save
npm install @types/bootbox --save
我想在我的 Angular2 项目中使用 Bootbox。我搜索了很多,但没有任何适合我的解决方案。
我也试过 angular2-modal
但是在使用 angular2-modal
时有很多问题,请提出任何好的 doc/Examples/Demos 。
步骤 1: 通过 npm install bootbox --save
第 2 步: 如果您使用的是 systemjs,则包括 bootbox,例如:
<script src="node_modules/bootbox/bootbox.js"></script>
第 3 步: 只需在导入所有库之后和组件装饰器之前将 declare var bootbox:any;
放在组件 ts 文件中,然后像 bootbox.alert("Hello world!");
函数调用。
确保您已安装 bootstrap 和 jquery 并包含在索引页中。 jquery 应该排在第一位,然后在 bootstrap 之后。
[编辑]
替代步骤 3
而不是 declare var bootbox:any;
,而是导入类型类型定义:
npm install @types/jquery --save
npm install @types/bootbox --save