在 Typescript/Angular2 中显示引导箱警报? [英] Show bootbox alert in Typescript/Angular2?

查看:17
本文介绍了在 Typescript/Angular2 中显示引导箱警报?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在我的 Angular2 项目中使用 Bootbox.我搜索了很多,但没有任何适合我的解决方案.
我也尝试了 angular2-modal,但是在使用 angular2-modal 时出现了很多问题,请推荐任何好的文档/示例/演示.

I want to use Bootbox in my Angular2 project. I searched a lot but there is no any relevant solution for me.
I also tried angular2-modal but there were many issues while using angular2-modal, please suggest any good doc/Examples/Demos for the same.

推荐答案

第一步: 通过 npm install bootbox --save

第 2 步:如果您使用的是 systemjs,则包括 bootbox,如:

Step 2: If you are using systemjs then include bootbox like:

<script src="node_modules/bootbox/bootbox.js"></script>

第 3 步: 只需将 declare var bootbox:any; 放在组件 ts 文件中导入所有库之后和组件装饰器之前,然后像 bootbox 一样正常使用.alert("Hello world!"); 在任何函数调用上.

Step 3: Just put declare var bootbox:any; after import all libreries and before component decorator in your component ts file and then use normaly like bootbox.alert("Hello world!"); on any function call.

确保您已安装 bootstrapjquery 并将其包含在索引页面中.jquery 应该排在第一位,然后在 bootstrap 之后.

Make sure you have bootstrap and jquery installed and included in index page. jquery should be in first place then after bootstrap.

备用步骤 3而不是 declare var bootbox:any;,而是导入类型类型定义:

Alternate Step 3 Instead of declare var bootbox:any;, import type type definitions instead:

npm install @types/jquery --save
npm install @types/bootbox --save

这篇关于在 Typescript/Angular2 中显示引导箱警报?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆