2017-08-17 55 views
0

我正在使用角度js並進行restcall。但是我有一個變量,當我把這個變量放在服務中時,這個變量有一些值,然後在控制檯中編碼這個變量值。防止使用post方法編碼其餘的調用方法使用角度js

REST調用

var rep = "CX-0138_ES48A9CA"; 

    Rh.all('example/demo/db ').post(" ",+JSON.stringify(rep)).then(function(resp) 
    { 

    }) 

則代表值不在控制檯URL存在。

enter image description here

但是,當我除去編碼+ JSON.stringify然後服務(URL)。在控制檯
enter image description here

如何在POST方法設置代表CX-0138_ES48A9CA的價值

var rep = "CX-0138_ES48A9CA"; 

    Rh.all('example/demo/db ').post(" ",rep).then(function(resp) 
    { 

    }) 

編碼後的服務。

+0

在爲什麼ü想使用url變量後? –

+0

@Noman我想用郵政方式發送一些id代表 –

回答

0

試試這個:

Rh.all('example/demo/db ').post({rep: encodeUriComponent(rep)}).then(function(resp) 
    { 

    }) 
+0

這是防止編碼,但在URL「rep =」是添加,然後打網址會有所不同。 –

+0

不完全確定你的意思,但請使用encodeUriComponent –

+0

查看我的更新答案。我明白了。感謝Andrei –