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 联系我们: