使用angularjs列出JSON中的字段值

[英]Listing field values from JSON using angularjs


With respect to question StackOverflow , even I was looking some thing like that only . But it has to eliminate repeating values. Can any one please help me in this.

关于StackOverflow问题,即使我只是在寻找类似的东西。但它必须消除重复的价值。任何人都可以帮助我。

FOR example $scope.notes=[{"id":"id1", "text":"text1"}, {"id":"id2", "text":"text2"}, {"id":"id2", "text":"text1"}]; This will list all the "text values" from notes JSON data , but it will repeat text1 value twice. Can we make it to display only once.

例如$ scope.notes = [{ “ID”: “ID1”, “文”: “text1” 中的},{ “ID”: “ID2”, “文”: “文本2”},{ “ID”:” id2“,”text“:”text1“}];这将列出Notes JSON数据中的所有“文本值”,但它将重复text1值两次。我们可以让它只显示一次。

1 个解决方案

#1


1  

Try with this.

试试这个。

 <div ng-model="modelName" ng-repeat="note in notes | unique:'text'">
    <div>{{note.text}}</div>
 </div>

注意!

本站翻译的文章,版权归属于本站,未经许可禁止转摘,转摘请注明本文地址:http://www.silva-art.net/blog/2016/05/14/6016683febc95895835b4e99e059e68d.html



 
© 2014-2018 ITdaan.com 粤ICP备14056181号