Single quote ( ' ) is not supporting in angula

2019-08-19 10:10发布

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条回答
唯我独甜
2楼-- · 2019-08-19 10:50

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

查看更多
登录 后发表回答