krikke999
krikke999

Reputation: 33

angularjs: ng-model onwatch only triggers once

I'm trying to use filtering and sorting with Angularjs, but my filter only fires once. I have looked at alot of other samples but it is not clear to me why this only fires once.

HTML

Search: <input ng-model="query.$">
From: <input ng-model="query.From">
DepartureTime: <input ng-model="query.DepartureTime">

JS $scope.$watch('query', function (newValue, oldValue) { /* */ }

http://jsfiddle.net/E4V7X/

Upvotes: 0

Views: 151

Answers (1)

ms87
ms87

Reputation: 17492

You need to deep watch query since you're looking for changes in it's child properties, you do that by passing true as the third argument of $watch

$scope.$watch('query', function (newValue, oldValue) {
//
},true)

Upvotes: 0

Related Questions