AngularJS - 为什么我的表达式不能访问我的模型

时间:2013-06-08 08:30:54

标签: angularjs

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

the scopes should render the empty navigation on the left

                    <!-- 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>`

1 个答案:

答案 0 :(得分: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>