简体   繁体   中英

Meanjs How to link one query to a different controller

I have one crud-module called article and anther one called Devices. I would like the data from article crud-module to be also in Device article. Does anyone have an idea how to implement this?

devicesApp.controller('DevicesController', ['$scope', '$stateParams', '$location', 'Authentication', 'Devices','$modal', '$log',
function($scope, $stateParams, $location, Authentication, Devices, $modal, $log) {
    $scope.authentication = Authentication;
    $scope.devices = Devices.query();   

And here is my articles query

$scope.articles = Articles.query();

You can't (and shouldn't) communicate with controllers like this. In order for this code to work, Articles and Devices need to be factories or services.

devicesApp.factory('Articles', function(){
  return {
    query: function(){
      return {/*Your data here*/};
    };
  };
});

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM