基于json值的Angularjs ng重复过滤器

基于json值的Angularjs ng重复过滤器,angularjs,angularjs-ng-repeat,angularjs-filter,Angularjs,Angularjs Ng Repeat,Angularjs Filter,我这里有一个失物招领- 我在这里使用虚拟json- 我希望根据json中的值在页面的不同部分显示json内容 因此,值为Section的故事:“New”将显示在一个div中,“Old”将显示在另一个div中 这在显示“New”的第一个div中有效,但在只显示“Old”的第二个div中,它显示所有故事 过滤器是否有问题,或者与页面的顺序有关 <div class="container" data-ng-controller="myCtrl">

我这里有一个失物招领-

我在这里使用虚拟json-

我希望根据json中的值在页面的不同部分显示json内容

因此,值为Section的故事:“New”将显示在一个div中,“Old”将显示在另一个div中

这在显示“New”的第一个div中有效,但在只显示“Old”的第二个div中,它显示所有故事

过滤器是否有问题,或者与页面的顺序有关

        <div class="container" data-ng-controller="myCtrl">

            <div class="row">

                <div  class="col-sm-6">
                    <div class="story" data-ng-repeat="story in stories | filter: story.Section='New' " >
                        {{story.Title}}
                        {{story.Section}}
                    </div>
                </div>

                <div  class="col-sm-6">
                    <div class="story" data-ng-repeat="story in stories | filter: story.Section='Old' ">
                        {{story.Title}}
                        {{story.Section}}
                    </div>
                </div>

            </div>

        </div>

{{story.Title}
{{story.Section}
{{story.Title}
{{story.Section}

这是使用
过滤器进行过滤的方法

            <div  class="col-sm-6">
                <div class="story" data-ng-repeat="story in stories | filter: {Section:'New'}" >
                    {{story.Title}}
                    {{story.Section}}
                </div>
            </div>

            <div  class="col-sm-6">
                <div class="story" data-ng-repeat="story in stories | filter: {Section:'Old'}">
                    {{story.Title}}
                    {{story.Section}}
                </div>
            </div>

{{story.Title}
{{story.Section}
{{story.Title}
{{story.Section}

它采用对象语法<代码>=
是赋值运算符。请参见这是使用
过滤器进行过滤的方法

            <div  class="col-sm-6">
                <div class="story" data-ng-repeat="story in stories | filter: {Section:'New'}" >
                    {{story.Title}}
                    {{story.Section}}
                </div>
            </div>

            <div  class="col-sm-6">
                <div class="story" data-ng-repeat="story in stories | filter: {Section:'Old'}">
                    {{story.Title}}
                    {{story.Section}}
                </div>
            </div>

{{story.Title}
{{story.Section}
{{story.Title}
{{story.Section}

它采用对象语法<代码>=
是赋值运算符。请参见

在筛选器中明确指定表达式,它将起作用

工作冲击器:


{{story.Title}
{{story.Section}
{{story.Title}
{{story.Section}

在过滤器中明确指定表达式,它将起作用

工作冲击器:


{{story.Title}
{{story.Section}
{{story.Title}
{{story.Section}

如果你找不到解决方案,你可以添加一个
ng If
过滤所需对象。嗯……这看起来很奇怪如果你找不到解决方案,你可以添加一个
ng If
过滤所需对象。嗯……这看起来很奇怪