2

我有一个带有 2 个视图、列表视图和单个项目视图的投票应用程序。这些是 Angular 客户端控制器中的初始化函数

        // Poll List
        $scope.pollList = function(){
            $scope.votes = Votes.query({
                userId:Authentication.user._id
            });             
            $scope.polls = Polls.query();
        };

        // View Poll
        $scope.findOne = function(){
            $scope.votes = Votes.query({
                userId:Authentication.user._id
            });
            $scope.poll = Polls.get({
                pollId: $stateParams.pollId
            });
            $scope.categories = Categories.query();
            $scope.languages = Languages.query();
            $scope.pollItem($scope.poll);
        };

        // Poll Item
        $scope.pollItem = function(poll){
            $scope.pollVoted(poll);
            $scope.countPollVotes(poll);
            for (var i = 0; i < poll.poll_options.length; i++){
                $scope.optionItem(poll,poll.poll_options[i]);
            };
        };

列表视图和单个视图都在每个 poll 对象中启动 pollItem 函数。在列表视图中,一切正常 - 每个轮询对象都通过 pollItem 函数而没有错误。但在单个投票视图中,我收到错误,即投票的不同属性(即用户、评论、poll_options)返回未定义!尽管当我 console.log 投票对象时,我可以在那里看到它们。请帮忙!我知道这听起来有点含糊,但我不确定要提供哪些其他细节。我在这个问题上停留了几天,没有找到答案。

4

0 回答 0