hey jon, have you solved this? i am having the same problem

On Monday, March 11, 2013 at 8:43:20 PM UTC+2, Jon Rimmer wrote:
>
> Hi,
>
> I have an ng-repeat with an orderBy filter to sort it. The orderBy filter 
> is supplied a function that extracts a property for sorting. The function 
> also uses another property, on the parent scope, to control exactly what 
> property is extracted.
>
> Simplified, pseudo-code:
>
> <div ng-repeat="item in items | orderBy:myFilterFunction">
>    ...
> </div>
>
> function Controller() {
>    ...
>    $scope.whichPropertyToSortBy = 'x';
>
>    $scope.myFilterFunction = function(item) {
>        if ($scope.whichPropertyToSortBy == 'x') {
>            return some calculated expression;
>        }
>        else
>        {
>            return some other calculated expression;
>        }
>    }
> }
>
> The problem is, when $scope.whichPropertyToSortBy is changed, as the 
> result of some other action like a button click, Angular does not reorder 
> the items. How can I arrange things so Angular realises that myFilterFunction 
> has a dependency on whichPropertyToSortBy? Or can I force an update of 
> the ng-repeat somehow?
>
> I've come to Angular from Knockout, where it's fairly trivial to express 
> these kind of dependencies. It seems like Angular's dirty-checking works 
> well for models with primitive properties, but not ones where things need 
> to be computed dynamically. Maybe I just need to shift my mindset as to how 
> to handle these sort of things in Angular?
>

-- 
You received this message because you are subscribed to the Google Groups 
"AngularJS" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/angular.
For more options, visit https://groups.google.com/d/optout.

Reply via email to