I have a controller like this :
var moduleFichiersDupliques = angular.module('fichiersDupliques', []);
moduleFichiersDupliques.controller("FichiersDupliquesController", [ '$http', '$log', function($http, $log) {
var store = this;
$http.get('groupes-dupliques-data.json').success(function(data) {
store.groupesDupliquesData = data;
});
this.getNombreFichiersDansGroupe = function(groupe) {
return groupe.fichiers.length;
};
this.getTailleFichier = function(groupe) {
return groupe.tailleTotale / this.getNombreFichiersDansGroupe(groupe);
};
this.getTailleGaspillee = function(groupe) {
var tailleGaspillee = groupe.tailleTotale - this.getTailleFichier(groupe);
return tailleGaspillee;
};
}]);
and a ng-repeat in my html code
<td ng-repeat="groupe in fichiersDupliquesCtrl.groupesDupliquesData | orderBy:fichiersDupliquesCtrl.getTailleGaspillee:true">
{{fichiersDupliquesCtrl.getTailleGaspillee(groupe)}}
</td>
And I get this error :
TypeError: Cannot read property 'getTailleFichier' of undefined
at getTailleGaspillee (/test/js/fichiersdupliques.js:26:58)
at Array.<anonymous> (/test/js/angular-1.3.0.js:17321:24)
at comparator (/test/js/angular-1.3.0.js:17330:36)
at /test/js/angular-1.3.0.js:17337:34
at Array.sort (native)
at /test/js/angular-1.3.0.js:17326:22
at $parseFilter (/test/js/angular-1.3.0.js:11939:19)
at Object.interceptedExpression (/test/js/angular-1.3.0.js:12579:21)
at Scope.$digest (/test/js/angular-1.3.0.js:13957:40)
at Scope.$apply (/test/js/angular-1.3.0.js:14227:24)
How can I refactor my code so that this function can be used in both a custom orderBy function and in my html page ?