2016-12-14 17 views
0

我有一個產品表,我做了一個高級研究,點擊一行看到的細節,然後點擊取消按鈕返回列表,我所有的研究投入將是空的...返回上一頁並保持更改angularjs

是否有可能回到我所在的位置?我的意思是我以前的研究或上一頁? 我想基於ng模型來做到這一點,有沒有另一種方式?

謝謝。

+0

請加爲了看你到目前爲止做了什麼一些代碼,並且要明確做什麼。你所描述的可以通過許多方式來完成。乾杯! – lealceldeiro

+0

我可以知道你使用的路由嗎?我的意思是'ng-route'或'ui-route'? –

+0

[歷史API](https://developer.mozilla.org/en-US/docs/Web/API/History)和[popstate event](https://developer.mozilla.org/en-US/) docs/Web/Events/popstate)用於此目的。在AngularJS中,這些API在HTML 5模式下由[ngRoute](https://docs.angularjs.org/api/ngRoute)使用。 – georgeawg

回答

0

這些解決方案可能會對您有所幫助。

Angular - ui-router get previous state

How do I get the Back Button to work with an AngularJS ui-router state machine?

http://blogs.candoerz.com/question/182248/angular-ui-router-get-previous-state.aspx

或多或少相同的答案,在所有這些環節我發現的。

$rootScope.$on('$stateChangeSuccess', function (ev, to, toParams, from, fromParams) { 
 
    //assign the "from" parameter to something 
 
});

+0

它適用於往返於但從出發地到出發地和從出發地始終爲空。 – slama

+0

我不知道我是否很好地解釋了我想要做什麼或不做什麼。事實上,如果我諮詢一行的細節並回到結果中,我不想鬆散我的高級研究結果。 – slama