Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/angularjs/24.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Angularjs 一个控制器到另一个作用域,并以角度共享_Angularjs - Fatal编程技术网

Angularjs 一个控制器到另一个作用域,并以角度共享

Angularjs 一个控制器到另一个作用域,并以角度共享,angularjs,Angularjs,Angular一开始很容易理解,但今天我完全不知所措,非常感谢这里为我遇到的这个问题提供的任何帮助 所以我有一个两栏的页面,一边是过滤器,另一边是要过滤的内容列表。这个页面是使用注入DOM的html创建的。我有一个过滤器模板和一个列表模板,它们都有自己的控制器filterCtrl和filterCtrl 我知道我需要将控制器的http请求分离到工厂中,因此目前我应用程序中的工厂和控制器示例如下所示 fpApp.controller('listController', ['$scope', 'eve

Angular一开始很容易理解,但今天我完全不知所措,非常感谢这里为我遇到的这个问题提供的任何帮助

所以我有一个两栏的页面,一边是过滤器,另一边是要过滤的内容列表。这个页面是使用注入DOM的html创建的。我有一个过滤器模板和一个列表模板,它们都有自己的控制器filterCtrl和filterCtrl

我知道我需要将控制器的http请求分离到工厂中,因此目前我应用程序中的工厂和控制器示例如下所示

fpApp.controller('listController', ['$scope', 'eventsFactory',
    function($scope, eventsFactory) {
        eventsFactory.eventList().then(
            function(data){
                $scope.events = data;
            }
        );
    }
]);

现在一切都很好,我有一个由部分组成的界面,所有的东西都在输出我需要的东西。我的问题是,我需要将这些过滤器应用到列表中,但不知道如何将一个控制器中的信息传递到另一个控制器,甚至不知道如何将一个模板传递到另一个。。一旦我能够从一个到另一个获取数据,我就很好了

fpApp.config(function($stateProvider, $urlRouterProvider) {
    //
    // For any unmatched url, redirect to /state1
    $urlRouterProvider.otherwise("/grid");
    //
    // Now set up the states
    $stateProvider
        .state('grid', {
            url: '/grid',
            views: {
                // the main template will be placed here (relatively named)
                '': { templateUrl: '/templates/grid.html' },
                'filerList@grid': { 
                    templateUrl: '/templates/partials/filterList.html', 
                    controller: 'filterCtrl'
                },
                'viewSwitch@grid': { 
                    templateUrl: '/templates/partials/viewSwitch.html'
                },
                'eventList@grid': { 
                    templateUrl: '/templates/partials/eventList.html',
                    controller: 'listController'
                }
            }
        })
        .state('list', {
            url: '/list',
            views: {
                // the main template will be placed here (relatively named)
                '': { templateUrl: '/templates/list.html' },
                'filerList@list': { 
                    templateUrl: '/templates/partials/filterList.html',
                    controller: 'filterCtrl'
                },
                'viewSwitch@list': { 
                    templateUrl: '/templates/partials/viewSwitch.html'
                },
                'eventList@list': { 
                    templateUrl: '/templates/partials/eventList.html',
                    controller: 'listController'
                }
            }

        });
});
总之,当用户在filterController中单击filters时,我如何影响列表控制器


提前感谢您的时间。

搜索控制器之间共享数据的angularjs,有很多想法。一个共享服务,一些活动。我需要更多建设性的信息,为什么?我的结构是否有误?我没有提供足够的信息或解释得很糟糕吗???@NikosParaskevopoulos谢谢
fpApp.config(function($stateProvider, $urlRouterProvider) {
    //
    // For any unmatched url, redirect to /state1
    $urlRouterProvider.otherwise("/grid");
    //
    // Now set up the states
    $stateProvider
        .state('grid', {
            url: '/grid',
            views: {
                // the main template will be placed here (relatively named)
                '': { templateUrl: '/templates/grid.html' },
                'filerList@grid': { 
                    templateUrl: '/templates/partials/filterList.html', 
                    controller: 'filterCtrl'
                },
                'viewSwitch@grid': { 
                    templateUrl: '/templates/partials/viewSwitch.html'
                },
                'eventList@grid': { 
                    templateUrl: '/templates/partials/eventList.html',
                    controller: 'listController'
                }
            }
        })
        .state('list', {
            url: '/list',
            views: {
                // the main template will be placed here (relatively named)
                '': { templateUrl: '/templates/list.html' },
                'filerList@list': { 
                    templateUrl: '/templates/partials/filterList.html',
                    controller: 'filterCtrl'
                },
                'viewSwitch@list': { 
                    templateUrl: '/templates/partials/viewSwitch.html'
                },
                'eventList@list': { 
                    templateUrl: '/templates/partials/eventList.html',
                    controller: 'listController'
                }
            }

        });
});