i'm just wondering how to escape a function if it has quotes inside. for example, my variable is:
{{ video.Id }} = "Don't";
then if my markup in html is like this:
<button ng-click="executeFunc('{{video.Id}}')"/>
I will have an error saying that I have unterminated quotes. (Coming from the variable that have quotes inside.) Any help would be appreciated! thank you
Javascript uses '\' (backslash) in front as an escape character. To print quotes, using escape characters we have two options: For single quotes: \' (backslash followed by single quote) For double quotes: \” (backslash followed by double quotes)
We can use the backslash ( \ ) escape character to prevent JavaScript from interpreting a quote as the end of the string. The syntax of \' will always be a single quote, and the syntax of \" will always be a double quote, without any fear of breaking the string.
You don't need the inner {{}}, just do <button ng-click="executeFunc(video.Id)"/>
Your controller function, executeFunc
will get the proper value.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With