AngularJS和HTML:在onclick函数的变量内转义引号

[英]AngularJS and HTML: Escaping quotes inside a variable for an onclick function


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:

那么如果我在HTML中的标记是这样的:

    <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

我会有一个错误,说我有未终止的引号。 (来自内部引用的变量。)任何帮助将不胜感激!谢谢

1 个解决方案

#1


8  

You don't need the inner {{}}, just do <button ng-click="executeFunc(video.Id)"/>

您不需要内部{{}},只需执行

Your controller function, executeFunc will get the proper value.

您的控制器函数executeFunc将获得正确的值。


注意!

本站翻译的文章,版权归属于本站,未经许可禁止转摘,转摘请注明本文地址:https://www.itdaan.com/blog/2013/12/11/b240784a5746ef7d3e8030f8691aac37.html



 
  © 2014-2022 ITdaan.com 联系我们: