Single quote ( ' ) is not supporting in angularjs ng-click() if multiple parameter is passed

牧云@^-^@ 提交于 2019-12-25 01:35:41

问题


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}');"

this my angular controller:

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


回答1:


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))}'"

Also JSP javascript escape with JSTL



来源:https://stackoverflow.com/questions/47652236/single-quote-is-not-supporting-in-angularjs-ng-click-if-multiple-paramet

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!