听在Angularjs应用Firepad事件 [英] Listening for Firepad events in Angularjs app

查看:138
本文介绍了听在Angularjs应用Firepad事件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

只是想知道是否有可能在Angularjs应用监听Firepad事件?

Just wondered if it's possible to listen for Firepad events in an Angularjs app?

我看到标准的js code检测时Firepad准备的是:

I see the standard js code for detecting when Firepad is ready is:

firepad.on('ready', function() {
  // Firepad is ready.
});

http://www.firepad.io/docs/#api

但我怎么能在角检测该控制器内?

but how can I detect this within a controller in Angular?

推荐答案

你已经有code,在控制器初始化Firepad?即像 VAR firepad = Firepad.from codeMIRROR 。如果是这样,你应该能够听ready事件上,同样作为普通的JavaScript。如果你没有这样的code然而,你可以找到它在初始化Firepad firepad.io/docs/#api的部分。

Do you already have code that initializes Firepad in your controller? I.e. something like var firepad = Firepad.fromCodeMirror. If so, you should be able to listen to the ready event on that the same as in plain JavaScript. If you don't have such code yet, you can find it in the Initializing Firepad section of firepad.io/docs/#api.

要让它感觉更综合的,你很可能在指令包firepad很容易。但有,这是否一个图书馆吗?更适合于谷歌比计算器。

To make it feel more integrated, you could probably wrap firepad in a directive quite easily. But "is there a library that does this?" is better suited for google than for StackOverflow.

这是说,这个库看起来很有希望:<一href=\"https://github.com/davideast/FireDeck/blob/436fa59fb65a186beec857865c156ce2ada809e2/scripts/directives/firepad.js\" rel=\"nofollow\">https://github.com/davideast/FireDeck/blob/436fa59fb65a186beec857865c156ce2ada809e2/scripts/directives/firepad.js.这似乎引进了&LT; FIRE-PAD 从我可以快速收集在演示现场元素:的 http://fire-deck.firebaseapp.com

That said, this library looks promising: https://github.com/davideast/FireDeck/blob/436fa59fb65a186beec857865c156ce2ada809e2/scripts/directives/firepad.js. It seems to introduce a <fire-pad element from what I can quickly gather in the demo site: http://fire-deck.firebaseapp.com.

请注意上面也是大卫的评论:

Note David's comment above too:

那作者&LT; FIRE-PAD&GT; 此指令。这不是一般使用一个很不错的指令。我紧挨着一个IFRAME的浏览器编码做加之它。但是,它可以很容易地进行修改,而不iframe来工作。你可能真的只是删除这些线路在这里:<一href=\"https://github.com/davideast/FireDeck/blob/436fa59fb65a186beec857865c156ce2ada809e2/scripts/directives/firepad.js#L72-L80\" rel=\"nofollow\">https://github.com/davideast/FireDeck/blob/436fa59fb65a186beec857865c156ce2ada809e2/scripts/directives/firepad.js#L72-L80

Author of that <fire-pad> directive here. It's not a very good directive for general use. I tightly coupled it with an iframe to do in browser coding. However, it can easily be modified to work without the iframe. You could really just delete these lines here: https://github.com/davideast/FireDeck/blob/436fa59fb65a186beec857865c156ce2ada809e2/scripts/directives/firepad.js#L72-L80

这篇关于听在Angularjs应用Firepad事件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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