Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fails to copy to clipboard when value is JavaScript #72

Open
axelferdinand opened this issue Jun 24, 2015 · 6 comments
Open

Fails to copy to clipboard when value is JavaScript #72

axelferdinand opened this issue Jun 24, 2015 · 6 comments

Comments

@axelferdinand
Copy link

I'm creating a "copy code" function that currently is working perfectly copying HTML and SCSS. When I do an attempt to copy a field with JS, nothing happens. If I replace the JS with something else (text, HTML or CSS i.e) it works perfectly. How can we make the script copy JS code?

@asafdav
Copy link
Owner

asafdav commented Jun 24, 2015

Can you please create a live demo I can check ?

On Wed, Jun 24, 2015 at 1:49 PM, Axel Ferdinand [email protected]
wrote:

I'm creating a "copy code" function that currently is working perfectly
copying HTML and SCSS. When I do an attempt to copy a field with JS,
nothing happens. If I replace the JS with something else (text, HTML or CSS
i.e) it works perfectly. How can we make the script copy JS code?


Reply to this email directly or view it on GitHub
#72.

@axelferdinand
Copy link
Author

In my prototype, I'm pulling HTML, SCSS and JS from individual files, but the output is as illustrated in this demo:

http://plnkr.co/edit/bnB0d5sP7viZmj5cLgrM?p=preview

@asafdav
Copy link
Owner

asafdav commented Jun 24, 2015

You should not use ng-init for that, your code is invalid. you can see the
Plunker errors as well

On Wed, Jun 24, 2015 at 2:20 PM, Axel Ferdinand [email protected]
wrote:

In my prototype, I'm pulling HTML, SCSS and JS from individual files, but
the output is as illustrated in this demo:

http://plnkr.co/edit/bnB0d5sP7viZmj5cLgrM?p=preview


Reply to this email directly or view it on GitHub
#72 (comment).

@axelferdinand
Copy link
Author

OK, I see. How can I copy the code inside these elements then:

<'pre rel="HTML"'><'code class="language-markup" id="markup"'> CODE GOES HERE <'/code'><'/pre'>

Can't get my head around how to use your script to copy content inside pre or code element.

@asafdav
Copy link
Owner

asafdav commented Jun 24, 2015

I'm not sure I follow you, you can use any value that is stored in your
$scope or any valid expression

On Wed, Jun 24, 2015 at 2:49 PM, Axel Ferdinand [email protected]
wrote:

OK, I see. How can I copy the code inside these elements then:

{{ content|sanitize }}

Can't get my head around how to use your script to copy content inside pre
or code element.


Reply to this email directly or view it on GitHub
#72 (comment).

@axelferdinand
Copy link
Author

Let's say I have put some code inside a <'pre'> or <'code'> element. If I give the <'code'> element a ng-model, it is by default emptied by Angular, and I'm not able to copy the content from it. I simply wan't to be able to copy ANY content from inside a <'code'> element. How can I do that, using your script?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants