私は車のために次の配列を持っています。私はこの配列のng-optionsを使用して、 "all colors"オプションとともにリンクとしての色カテゴリのみを表示しようとしています。一意のng-optionsは機能しません
すべて、私が削除した場合
<div ng-repeat="client in clients">
<label>{{client.Name}}</label>
<select ng-model="opt" ng-options="i.color for i in client.cars | unique: 'color'">
<option value="">All</option>
<option value="">{{i.color}}</option>
</select>
</div>
、赤、黄、青「|ユニーク: 『色』」構文を、私は繰り返しですべての色を取得します。
構文から "| unique:color"を保持すると、エラー:angular.js:13424エラー:[$ injector:unpr]不明なプロバイダ:uniqueFilterProvider < - uniqueFilter。 独自のフィルタ機能を使用するために私のhome.htmlにui-filters.js(https://cdnjs.cloudflare.com/ajax/libs/angular-filter/0.5.8/angular-filter.js)を含めましたが、それはそれを拾いません。 はまた、私の主な角度モジュールは、このようなものです:
angular.module("cartApp", [])
.controller('fs',function($scope,$http){
//code here
});
私は問題がangularJS UIモジュールをincudingされる可能性がありますbeleve。 '[]'を '[' ui.filters ']に変更すると、モジュールを認識しません。
clients:
[
"Name":'test',
"age":34,
cars:
[
{
"carid": 1,
"carname": 'camry',
"color": 'red'
},
{
"carid": 2,
"carname": 'mustang',
"color": 'red'
},
{
"carid": 3,
"carname": 'landcruiser',
"color": 'yellow'
},
{
"carid": 4,
"carname": 'focus',
"color": 'blue'
},
{
"carid": 5,
"carname": 'civic',
"color": 'blue'
}
]
]
ここで何かが間違っていると思いますか?あなたの配列は2赤、2赤1赤です。したがって、一意性を削除すると、すべてのデータが表示されます。もしそうでなければ間違ってしまう。 –
混乱して申し訳ありません。構文から "| unique:color"を維持すると、エラー:angular.js:13424 Error:[$ injector:unpr]不明なプロバイダ:uniqueFilterProvider < - uniqueFilter – hss
混乱してごめんなさい。構文から "| unique:color"を維持すると、エラー:angular.js:13424エラー:[$ injector:unpr]不明なプロバイダ:uniqueFilterProvider < - uniqueFilter。ユニークなフィルタ機能を使用するためにui-filters.js(https://cdnjs.cloudflare.com/ajax/libs/angular-filter/0.5.8/angular-filter.js)が含まれていますが、それを選択していません。 – hss