Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/meteor/3.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
Meteor 改变路线时的奇怪行为_Meteor_Angular Meteor - Fatal编程技术网

Meteor 改变路线时的奇怪行为

Meteor 改变路线时的奇怪行为,meteor,angular-meteor,Meteor,Angular Meteor,我在订阅收藏时面临着奇怪的流星行为。我有一个抽象路由邮箱,下面有三个路由。Inbox、sent和singleMail(显示来自这两个邮箱的一封邮件的详细信息)。现在的问题是,当我在单个邮件路由中解析邮件集合时,它会为收件箱和已发送邮件绑定相同的邮件集合,尽管我为两者发布了不同的集合。 注意:它工作完美,直到我去从两个单一的邮件路线。例如,当我点击收件箱中的任何邮件或已发送的邮件时,它将转到单一邮件路径并显示电子邮件的详细信息。回来的时候。问题从这里开始。它为两者订阅邮件集合。i、 e如果收件箱中

我在订阅收藏时面临着奇怪的流星行为。我有一个抽象路由邮箱,下面有三个路由。Inbox、sent和singleMail(显示来自这两个邮箱的一封邮件的详细信息)。现在的问题是,当我在单个邮件路由中解析邮件集合时,它会为收件箱和已发送邮件绑定相同的邮件集合,尽管我为两者发布了不同的集合。 注意:它工作完美,直到我去从两个单一的邮件路线。例如,当我点击收件箱中的任何邮件或已发送的邮件时,它将转到单一邮件路径并显示电子邮件的详细信息。回来的时候。问题从这里开始。它为两者订阅邮件集合。i、 e如果收件箱中有6个,发送的有3个,则两者都会显示9。我试了好几个小时,但没有成功。 非常感谢您的帮助! 我粘贴了很多代码来解决我的确切问题。这是服务器中的mail.js

Meteor.publish("mails", function (obj) {

    //Will use for admin
    isAuth(this);

    var query = {identity:this.userId};
    if (obj) {
        query[obj.condition] = obj.id;
    }
    return Mails.find(query);

});

Meteor.publish("mailsTo", function (options) {
    //if user not logged in
    isAuth(this);
    Counts.publish(this, 'countOfNewMails', Mails.find({identity: this.userId, 'to.id': this.userId, unread: true}));
    Counts.publish(this, 'countOfToMails', Mails.find({identity: this.userId, 'to.id': this.userId}), { noReady: true });
    return Mails.find({identity: this.userId, 'to.id': this.userId}, options);
});

Meteor.publish("mailsFrom", function (options) {
    //if user not logged in
    isAuth(this);
    Counts.publish(this, 'countOfFromMails', Mails.find({identity: this.userId, from: this.userId}), { noReady: true });
    return Mails.find({identity: this.userId, from: this.userId}, options);
});
这是我的路线

angular.module('Secret')
    .config(['$urlRouterProvider', '$stateProvider', '$locationProvider',
        function($urlRouterProvider, $stateProvider, $locationProvider){

            $locationProvider.html5Mode(true);

            $stateProvider
                .state('home', {
                    url: '/home',
                    templateUrl: 'client/home/views/home.ng.html',
                    controller: 'homeCtrl'
                })
                .state('login', {
                    url: '/homes/:id/login',
                    templateUrl: 'client/login/views/login.ng.html',
                    controller: 'loginCtrl'
                })
                .state('signup', {
                    url: '/homes/:id/signup',
                    templateUrl: 'client/signup/views/signup.ng.html',
                    controller: 'signupCtrl'
                })
                .state('forgotPassword', {
                    url: '/homes/:id/forgot-password',
                    templateUrl: 'client/forgotPassword/views/forgotPassword.ng.html',
                    controller: 'forgotPasswordCtrl'
                })
                .state('profile', {
                    url: '/profile',
                    templateUrl: 'client/profile/views/profile.ng.html',
                    controller: 'profile'
                })
                .state('mailbox', {
                    url: '/mailbox',
                    templateUrl: 'client/mailBox/views/mailbox.ng.html',
                    controller: 'mailboxCtrl',
                    abstract: true
                })
                .state('mailbox.inbox', {
                    url: '/inbox',
                    templateUrl: 'client/inbox/views/inbox.ng.html',
                    controller: 'inboxCtrl',
                    resolve: {
                        "currentUser": ["$meteor", function($meteor){
                            return $meteor.requireUser();
                        }]
                    }
                })
                .state('mailbox.sent', {
                    url: '/sent',
                    templateUrl: 'client/sent/views/sent.ng.html',
                    controller: 'sentCtrl'
                })
                .state('mailbox.singleMail', {
                    url: '/:folder/:id',
                    params: {
                        hasnext: null
                    },
                    templateUrl: 'client/singleMail/views/single.ng.html',
                    controller: 'singleCtrl',
                    resolve: {
                        "currentUser": ["$meteor", function($meteor){
                            return $meteor.requireUser();
                        }],
                        statesSub: ['$meteor', '$stateParams', function($meteor, $stateParams) {
                            return $meteor.subscribe('mails', $stateParams.id);
                        }]
                    }
                })
                .state('mailbox.compose', {
                    url: '/compose/:r/:mailId',
                    templateUrl: 'client/compose/views/compose.ng.html',
                    controller: 'composeCtrl'
                })

            $urlRouterProvider.otherwise("/home");

        }])
    .run(['$rootScope', '$state',
        function($rootScope, $state){
        $rootScope.$on("$stateChangeError", function(event, next, previous, error) {
            // We can catch the error thrown when the $requireUser promise is rejected
            // and redirect the user back to the main page
            //if (error === "AUTH_REQUIRED") {
                $state.go("home");
            //}
        });
    }]);
在控制器中使用简单的SentCtrl

$scope.page = 1;
        $scope.perPage = 50;
        $scope.sort = { createdAt: -1 };

        //get reactively
        $meteor.autorun($scope, function() {
            $scope.mails = $scope.$meteorCollection(Mails).subscribe('mailsFrom',{
                limit: parseInt($scope.getReactively('perPage')),
                skip: (parseInt($scope.getReactively('page')) - 1) * parseInt($scope.getReactively('perPage')),
                sort: $scope.getReactively('sort')
            })
        })
InboxCtrl

$scope.page = 1;
    $scope.perPage = 50;
    $scope.sort = { createdAt: -1 };

    $scope.pagechanged = function(sign){
        sign ? $scope.page++ : $scope.page--;
    }

    //get reactively
    $meteor.autorun($scope, function() {
        $scope.inbox = $scope.$meteorCollection(Mails).subscribe('mailsTo',{
            limit: parseInt($scope.getReactively('perPage')),
            skip: (parseInt($scope.getReactively('page')) - 1) * parseInt($scope.getReactively('perPage')),
            sort: $scope.getReactively('sort')
        })
    })
在单一邮件中,我只是通过params接收邮件

$scope.currentMail = $meteor.object(Mails, $stateParams.id);
无论何时订阅集合,都会获得订阅句柄 为了这个。所以,当模板被破坏时,您可以停止它。(即。
subscription\u handle.stop())
在meteor angular中的
template.destromed()
上 上下文