我有这段代码,我正在尝试使用groupBy
过滤器。但是一旦我尝试加载angular-filter.js
,我就会收到上述错误。
HTML:
<!DOCTYPE HTML>
<html lang="en-US" ng-app="app">
<head>
<meta charset="UTF-8">
<title>Group By Data</title>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.22/angular.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/angular-filter/0.5.4/angular-filter.js"></script>
</head>
<body>
<!--<div ng-controller="dataController">
<ul ng-repeat="(key, value) in properties | groupBy: 'name'">
Group name: {{ key }}
<li ng-repeat="prop in value">
player: {{ prop.name }}
</li>
</ul>
</div>-->
</body>
</html>
JS:
angular.module('app',['angular.filter'])
.controller('dataController', function($scope)
{
$scope.properties = [
{name: 'Weight', Property: 'quintal', value:'50'},
{ name: 'Quanity', Propertys: 'L' , value:'40'},
{ name: 'Quantity', Property: 'ml' , value:'10'},
{ name: 'Height', Property: 'metres' , value:'10' },
{ name: 'Height', Property: 'cm' , value:'20'},
{name: 'Height', Property: 'inches' , value:'30'},
{ name: 'Size', Property: 'Fat' , value:'28' },
{ name: 'Size',Property: 'Slim', value:'48' },
{ name: 'Feature', Property: 'Sharp' , value:'9'},
{ name: 'Feature', Property: 'Bland', value:'2' },
{name: 'Weight', Property: 'KG', value:'10'},
{ name: 'Weight', Property: 'grams', value:'20' },
{ name: 'Weight', Property: 'ton' , value:'30'}
];
});
答案 0 :(得分:1)
无需在控制器中包含angular.filter
。它已在angular.min.js file
中定义。你不用担心那个。只需写下
angular.module('app',[])
.controller('dataController', function($scope, $filter)
{
if you want use filter just inject and then use
//$filter('filter')(array, expression, comparator)
});