0

我已经验证了所有 JSON 对象,并且它们已成功添加到 VoteCtrl 的 $scope(见右图)。据我所知,我的表达式应该从我的 JSON 模型中选择所需的数据。所以我的问题是,为什么这不起作用&我在这里缺少什么?

范围应呈现左侧的空导航

                    <!-- National -->
                    <li ng-repeat="nationalHeader in votingTopics" class="nav-header">
                        {{nationalHeader[0].name}}
                    </li>

                    <li ng-repeat="nationalTopic in votingTopics" class="active">
                        <a href="{{nationalTopic.National.topicLink}}">
                            {{nationalTopic.National.topicTitle}}
                        </a>
                    </li>


                    <!-- State -->
                    <li ng-repeat="stateHeader in votingTopics" class="nav-header">
                        {{stateHeader[0]}}
                    </li>

                    <li ng-repeat="stateTopic in votingTopics">
                        <a href="{{stateTopic.State.California.topicLink}}">
                            {{stateTopic.State.California.topicTitle}}
                        </a>
                    </li>


                    <!-- City -->
                    <li ng-repeat="cityHeader in votingTopics" class="nav-header">
                        {{cityHeader[0]}}
                    </li>

                    <li ng-repeat="cityTopic in votingTopics">
                        <a href="{{cityTopic.State.California.Sacramento.City.topicLink}}">
                            {{cityTopic.State.California.Sacramento.City.topicTitle}}
                        </a>
                    </li>


                    <!-- County -->
                    <li ng-repeat="countyHeader in votingTopics" class="nav-header">
                        {{countyHeader[0]}}
                    </li>

                    <li ng-repeat="countyTopic in votingTopics">
                        <a href="{{countyTopic.County.topicLink}}">
                            {{countyTopic.County.topicTitle}}
                        </a>
                    </li>`
4

1 回答 1

0

您没有调用正确获取对象的属性。在您的部分尝试以下National操作:

<!-- National -->
<li ng-repeat="nationalHeader in votingTopics" class="nav-header">
    {{ nationalHeader.National[0].name }}
</li>

<li ng-repeat="nationalTopic in votingTopics">
    <a href="{{nationalTopic.National.topicLink}}">
        {{nationalTopic.National[0].topicTitle}}
    </a>
</li>
于 2013-06-08T09:45:47.827 回答