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

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

问题描述

我想在我的Angular2项目中使用Bootbox.我进行了很多搜索,但没有任何相关的解决方案.
我也尝试了angular2-modal,但是在使用angular2-modal时遇到了很多问题,请同时提出任何好的文档/示例/演示.

解决方案

步骤1:通过npm install bootbox --save

安装启动箱

第2步:如果您使用的是systemjs,请添加如下引导框:

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

第3步:只需将declare var bootbox:any;导入所有库文件之后,并在组件ts文件中的组件装饰器之前,然后在任何函数调用上使用bootbox.alert("Hello world!");之类的常规字体即可.

确保已安装 bootstrap jquery 并包含在索引页面中. jQuery应该放在首位,然后再引导.

备用步骤3 代替类型declare var bootbox:any;,导入类型类型定义:

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

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.

解决方案

Step 1: Install bootbox via npm install bootbox --save

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

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

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.

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

[Edit]

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天全站免登陆