简体   繁体   English

如何在Typescript中使用Alertify?

[英]How to use Alertify in Typescript?

I'm relative new to Angular2 so be patient with me. 我是Angular2的新手,所以请耐心等待。

I tryed to use Alertify.js in my Angular2 project for a custom dialog box but i can't get Alertify running... I'm not that familiar with js so i tryed to use alertify.js in Typescript or rather tryed to make a module out of that alertify.js file. 试图在Angular2项目中使用Alertify.js创建自定义对话框,但我无法让Alertify运行...我对js不太熟悉,所以我尝试在Typescript中使用alertify.js,或者试图使该alertify.js文件中的一个模块。

I found something about using .d.ts files and I also found the alertify.d.ts file on github but I cant figure out how to use it. 我发现了一些有关使用.d.ts文件的信息,并且还在github上找到了alertify.d.ts文件,但我不知道该如何使用它。 I tryed several things but in the end I failed. 我尝试了几件事,但最终失败了。

Is there anyone who can help me with this problem or can show me an alternative for a custom dialogbox? 是否有人可以帮助我解决此问题,或者可以向我展示自定义对话框的替代方法?

如果你不希望使用tsdtypings ,然后最简单的方法是复制alertify.d.ts文件到您的源代码目录,包括alertify.js使用脚本标签,并在下一行添加到main.ts / boot.ts

/// <reference path="../path-to/alertify.d.ts" />

I figured out how to use Alertify as easy as possible for me. 我想出了如何尽可能方便地使用Alertify。

I just bound it to my index.html with 我只是将其绑定到我的index.html

<script src="alertify/alertify.min.js"></script>

and then just calling it alertify.METHODE() . 然后将其alertify.METHODE()

So making alertify global makes its very easy to use. 因此,将Alertify设置为全局使其易于使用。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM