簡體   English   中英

在路由時在不使用服務或Factory的情況下將JSON數據從控制器傳遞到另一個控制器

[英]Pass the JSON Data Between From Controller To another Controller with out using Services or Factory in angular JS while Routing

我在“ Dashboard頁面中有“對象”,當從“儀表板”中單擊“ Details頁面”時,它應該重定向到“ Details頁面,我想將JSON對象從“ Dashboard Controller傳遞到“ Details Controller ,有沒有辦法Angular JS Service或factory

myApp.controller('dashBoardController', ['$scope', function($scope) {

     $scope.detailsPage = function(Object){


     // I want this object available in details page controller

        $location.path('/detailsPage');
};

}]);

myApp.controller('detailsOageController', ['$scope', function($scope) {
  //  need Object data here
}]);

您可以通過以下方法實現從一個控制器到另一個控制器的數據共享。

  1. 使用服務/工廠(首選)
  2. 使用Rootscope和值將在全局范圍內(不可取)
  3. 發射與廣播

https://docs.angularjs.org/api/ng/type/ $ rootScope.Scope

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM