本文介绍了如果传递了多个参数,则angularjs ng-click()不支持单引号(')的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在angularjs ng-click中转义单引号(')

How to escape single quote( ' ) in angularjs ng-click

ng-click="editQuesAnsDetails('${fn:escapeXml(quesAnsList.querysearchBO.query)}','${fn:escapeXml(anslist.query_answer)}',

'${anslist.editUrl}','${anslist.filepath}');"

这是我的角度控制器:

App.controller('AskedQuesAnsController',['$scope','$window','AskedQuesAnsServices',function($scope,$window,AskedQuesAnsServices) { 
$scope.quesAnsUpdateCommand={"query":"","answer":"","editUrl":"","deleteUrl":""};
 $scope.editQuesAnsDetails = function(query,answer,editUrl,deleteUrl,filepath){

    $scope.quesAnsUpdateCommand.query=query;

    $scope.quesAnsUpdateCommand.answer=answer;
    $scope.quesAnsUpdateCommand.editUrl=editUrl;
    $scope.quesAnsUpdateCommand.deleteUrl=deleteUrl;
    $scope.quesAnsUpdateCommand.filepath=filepath;
    //alert($scope.moduleUpdateCommand.editModule);
 }

以上代码应适用于任何特殊符号

the above code should work for any special symboles

推荐答案

您可以尝试使用fn:replace()函数对单引号(')进行转义.

You can try using fn:replace() function to escape single quote( ').

<c:set var="singleQuotes">'</c:set>
<c:set var="singleQuotesReplace">\'</c:set>

ng-click="editQuesAnsDetails('${fn:escapeXml(
 fn:replace(quesAnsList.querysearchBO.query,singleQuotes,singleQuotesReplace))}'"

使用JSTL进行JSP javascript逸出

这篇关于如果传递了多个参数,则angularjs ng-click()不支持单引号(')的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-30 01:21