我的應用程序TimelineController和ReservationModalController中有兩個控制器。我想從ReservationModalController調用TimelineController並傳遞變量值。我想的是: 這是我app.jsAngular JS將參數一個控制器傳遞給另一個
$stateProvider
// Timeline
.state('timeline', {
url: '/timeline',
controller: 'TimelineController',
templateUrl: 'assets/partials/timeline.html',
params: {
operation: 'false'
}
})
這是TimelineController
$scope.operation = $state.current.params.operation;
,這是ReservationModalController:
$scope.edit = function() {
$modalInstance.close();
$state.go('timeline', {
operation: 'true'
});
};
在第一時間變量初始化。但是當我點擊按鈕和ReservationModalController並且它的方法edit
被稱爲TimelineController並且它的變量$scope.operation
不會更改。
請幫我解決了什麼問題?
看看這個:http://stackoverflow.com/questions/24842597/angular-controller-communication-with-a-service我猜你想你的控制器是能夠相互交談。 –
我知道這個解決方案,但在我的情況下,我不想使用這個。在角度我可以使用$ state.go()函數,但不工作,所以我很有趣,爲什麼? – zuri