2016-08-11 52 views
0

在我當前的代碼中發生了一些非常奇怪的事情。

所以我使用ng-repeat基於對象的數組,這樣就創建幾個要素:

<a ng-repeat="report in reports" ng-href="#/report?report={{report.id}}+file=0" ></a> 

我呈現的HTML看起來,只要我可以告訴正確這樣的:

<a ng-repeat="report in reports" ng-href="#/report?report=81+file=0" 
class="ng-scope" href="#/report?report=81+file=0"> 

如果我現在點擊此鏈接,我被重定向到這樣一個網址:

[root-url]/index.php#/report?report=84%20file%3D0 

當我真正當然希望能夠在這裏:

[root-url]/index.php#/report?report=84+file=0 

爲什麼「+」,第二個「=」符號翻譯這樣一來,當它是正確的鏈接,HREF屬性?任何人都有這個相同的問題?任何想法我做錯了什麼?

回答

1

它正在被URL編碼。它仍然具有相同的價值。

目前,您只有一個參數鍵入report,其值爲84 file=0。這種情況下的加號表示一個空格。

我假設你想要兩個參數:reportfile。要拆分URL中的參數,您必須使用&符號(&)而不是加號。

<a ng-repeat="report in reports" ng-href="#/report?report={{report.id}}&file=0" ></a> 
+0

謝謝,不知道爲什麼我沒有看到這個我自己。愚蠢的我 –