I am trying to do a simple array sort in a directive. But somehow when i put the nested array in the orderBy filter it is losing array and becomes an object (which can not be ordered)
when i log out the scope.item inside the directive it says: addresses: Array[2]
but when trying to filter using $filter('orderBy')(scope.item.addresses, 'distance'); i am getting "TypeError: object is not a function"
(function(angular){
'use strict';
angular.module('starter').directive('getDistance', function() {
return {
restrict: 'E',
replace: true,
link: function (scope, element, $filter) {
;
console.log(scope.item);
scope.item.addresses = $filter('orderBy')(, scope.item.addresses, 'distance');
console.log(scope.item.addresses);
}
};
});
})(window.angular);