我正在使用ui-router,並試圖檢測屬於正在轉換的視圖的控制器何時被破壞。ui-router:控制器是否在轉換後遭到破壞?
所以我現在有一個destroy
監聽器,如下:
$scope.$on('destroy', function(){
mySpecialFunction();
});
然而,當狀態發生變化時不同的看法\控制器,這種破壞活動永遠不會觸發。
我正在過渡到的狀態是兄弟狀態,所以我要從myParent.childA
到myParent.childB
(其中childA已添加了銷燬偵聽器)。
如果我是從myParent.childA
到myParent.childA.child1
,那麼這是有道理的,因爲childA仍然存在於層次結構中。
有人可以幫我理解爲什麼範圍在這種情況下仍然存在嗎?
可能的複製,這[SO後(HTTP提到的條件下被觸發:/ /stackoverflow.com/questions/16094940/what-is-the-lifecycle-of-an-angularjs-controller)應該幫助 – BBauer42
好的,謝謝,我看了一下,我不確定哪裏有什麼可以幫助的我 – mindparse