Angularjs 从多个控制器发送值

Angularjs 从多个控制器发送值,angularjs,Angularjs,我是AngularJS的新手,制作列表页面和编辑页面 这是我的app.js: angular.module('myApp', ['myApp.filters', 'myApp.services', 'myApp.directives', 'myApp.controllers']) .config(['$routeProvider', function ($routeProvider) { $routeProvider.when('/new', { temp

我是AngularJS的新手,制作列表页面和编辑页面

这是我的app.js:

angular.module('myApp', ['myApp.filters', 'myApp.services', 'myApp.directives', 'myApp.controllers'])
        .config(['$routeProvider', function ($routeProvider) {
            $routeProvider.when('/new', { templateUrl: 'partials/recipeForm.html', controller: 'add' })
                .when('/list', { templateUrl: 'partials/list.html', controller: 'listcontrol' })
                .when('/view/:recipeId', { templateUrl: 'partials/recipeForm.html', controller: 'edit' })
                .otherwise({ redirectTo: '/list' });
        }]);
这是我的controller.js:

angular.module('myApp.controllers', [])
        .controller('add', ['$scope', 'recipes', function ($scope, recipes) {
            alert("add");
        }])
        .controller('listcontrol', ['$scope', function ($scope) {
            alert("list");
            $scope.recipes = [{
                id: 0, 'title': 'Viral',
                'description': 'hello@gmail.com',
                'instructions': '123-2343-44'
            }, {
                id: 1, 'title': 'Viral',
                'description': 'hello@gmail.com',
                'instructions': '123-2343-44'
            }];
         }])
         .controller('edit', ['$scope', '$routeParams', function ($scope, $routeParams) {
             alert("edit");
             alert(JSON.stringify($scope.recipes)); // Undefined
         }]);

填充列表效果很好,但当我检查编辑时,它显示为未定义。我试图寻找解决办法,但没有找到

listcontrol
中的
$scope.recipes
edit
中的不同。您是如何在视图中实现此功能的?如果我在编辑中收到警报,则只有我可以转到视图。