0

i have a module with 2 routes:

admin.config(["$routeProvider", function ($routeProvider) {
            $routeProvider.when('/admin/companies', {
                templateUrl: "modules/" + 'admin/partials/adminCompanies.html',
                controller: AdminCompaniesController,
                resolve: {
                    'user': function (SecurityService) {
                        return SecurityService.authorize('admin');
                    }
                }
            });
        }]);

admin.config(["$routeProvider", function ($routeProvider) {
            $routeProvider.when('/admin/works/:id', {
                templateUrl: "modules/" + 'admin/partials/adminWorks.html',
                controller: AdminWorksController,
                resolve: {
                    'user': function (SecurityService) {
                        return SecurityService.authorize('admin');
                    }
                }
            });
        }]);

In AdminCompaniesController i have a function for go to /admin/works/:id but i need to send one object from $scope in AdminCompaniesController to $scope in AdminWorksController, How can i do it this? I dont have idea..

colymore
  • 11,776
  • 13
  • 48
  • 90

1 Answers1

0

Services are the go-to for passing data between controllers. Create a service and assign the data in your companies controller, then have your works controller read the data from that same service. There are countless examples of how to do this, but the example that comes to mind is here: How do I use $rootScope in Angular to store variables?.

Community
  • 1
  • 1
MBielski
  • 6,628
  • 3
  • 32
  • 43