美好的一天!我想問一下如何用單引號過濾產品名稱。例如,我想搜索「歐萊雅」品牌名稱,因爲單引號而導致錯誤。有人可以幫我解決這個問題嗎?以及如何將其插入控制器?謝謝!如何在控制器中插入單引號來過濾產品名稱
這是我在我的控制器檢索碼
$scope.filterSearch2nd = function(sid, bname, bcode, gnder, ptype, pname, size_oz, size_ml, size_g, size_pcs,scpidlist, brandnamelist, productnamelist) {
//console.log($scope.brandnamelistvalue.length);
brandnamelist="";
if(bname =="" && $scope.brandnamelistvalue.length<1) {
bname ="brandname";
}
else if($scope.brandnamelistvalue.length==1){
bname=$scope.brandnamelistvalue[0];
}
else{
bname="list";
for(var i=0;i<$scope.brandnamelistvalue.length;i++){
//console.log($scope.brandnamelistvalue[i]);
if(i==0)
brandnamelist+=$scope.brandnamelistvalue[i];
else
brandnamelist+=","+$scope.brandnamelistvalue[i];
}
}
$rootScope.loader = true;
skinCareProdService.filter2ndSearch(sid, bname, bcode, gnder, ptype, pname, size_oz, size_ml, size_g, size_pcs,scpidlist, brandnamelist, productnamelist)
.then(function(data){
$scope.rawSCP = data.data;
$rootScope.loader = false;
}
);
}
$("#search2nd").click(function(){
});
這是我在服務
function filter2ndSearch(list, bname, bcode, gnder, ptype, pname, size_oz, size_ml, size_g, size_pcs,scpidlist, brandnamelist, productnamelist){
return $http({
method: 'post',
url: rootURL + '/2ndlayer/search/' + list + '/' + bname + '/' + bcode + '/' + gnder + '/' + ptype + '/' + pname ,
data: $.param({
size_oz: size_oz,
size_ml: size_ml,
size_g: size_g,
size_pcs: size_pcs,
scpidlist: scpidlist,
brandnamelist: brandnamelist,
productnamelist: productnamelist
}),
headers: {
'Content-Type': 'application/x-www-form-urlencoded'
}
});
}
你可以分享你的代碼,你做了什麼?你得到什麼錯誤?分享所有這些細節。 – VicJordan
已更新@VicJordan –
看起來你不是URL編碼HTTP請求中使用的值。顯示你的skinCareProdService.filter2ndSearch方法的代碼。 – Phil