简体   繁体   English

将jsfiddle代码绑定到angularjs模型

[英]Bind jsfiddle code to angularjs model

I have created a front end using angularjs. 我用angularjs创建了一个前端。 In the form I want to let the user enter the javascript code for which I am using embedded JSfiddle. 在表单中,我想让用户输入我使用嵌入式JSfiddle的javascript代码。

    <iframe style="width: 100%; height: 300px" 
    src="http://jsfiddle.net/zalun/NmudS/embedded/"></iframe>

With jsfiddle they can enter the code and check the result there it self. 使用jsfiddle,他们可以输入代码并检查自己的结果。

I want to get save that code when the user submits the form. 我希望在用户提交表单时保存该代码。 How can I do that? 我怎样才能做到这一点?

or Suggest any other alternative of jsfiddle which will serve my purpose. 或建议jsfiddle的任何其他选择,这将符合我的目的。

The JSFiddle code is within an iframe, so doing a traditional Angular binding will be impossible. JSFiddle代码在iframe中,因此执行传统的Angular绑定是不可能的。 I looked around, and neither Codepen nor JSFiddle have support for both editing in an embed and downloading the raw resources that make up the pen. 我环顾四周,Codepen和JSFiddle都不支持嵌入编辑和下载构成笔的原始资源。 However, both Codepen and JSFiddle have API support for remote creation of pens. 但是,Codepen和JSFiddle都支持远程创建笔的API。 This is obviously a worse experience, but you could have the code form on your site provide a button which opens the user's code on Codepen or JSFiddle for testing, but they still submit the form on your site. 这显然是一种更糟糕的体验,但您可以在您的站点上提供代码表单,在Codepen或JSFiddle上打开用户代码进行测试,但他们仍然会在您的站点上提交表单。

Codepen API: https://blog.codepen.io/documentation/api/prefill/ Codepen API: https ://blog.codepen.io/documentation/api/prefill/

JSFiddle API: http://doc.jsfiddle.net/api/post.html JSFiddle API: http ://doc.jsfiddle.net/api/post.html

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

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