AngularJS和HTML:摆脱引号的变量里面一个onclick功能 [英] AngularJS and HTML: Escaping quotes inside a variable for an onclick function

查看:106
本文介绍了AngularJS和HTML:摆脱引号的变量里面一个onclick功能的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我只是想知道如何逃生功能,如果有引号内。
例如,我的变量是

i'm just wondering how to escape a function if it has quotes inside. for example, my variable is:

   {{ video.Id }} = "Don't";

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

then if my markup in html is like this:

    <button ng-click="executeFunc('{{video.Id}}')"/>

我将有一个错误,说我有未结束的引号。 (来自内部有引号的变量来了。)任何帮助将是AP preciated!谢谢

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

推荐答案

您不需要内部{{}},只是做&LT;按钮NG点击=executeFunc(video.Id )/&GT;

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

您控制器的功能, executeFunc 将得到应有的价值。

Your controller function, executeFunc will get the proper value.

这篇关于AngularJS和HTML:摆脱引号的变量里面一个onclick功能的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆