@@ -30,7 +30,7 @@ angular.module('ui.bootstrap.typeahead', [])
30
30
} ] )
31
31
32
32
//options - min length
33
- . directive ( 'typeahead' , [ '$compile' , '$q' , '$document' , 'typeaheadParser' , function ( $compile , $q , $document , typeaheadParser ) {
33
+ . directive ( 'typeahead' , [ '$compile' , '$parse' , '$ q', '$document' , 'typeaheadParser' , function ( $compile , $parse , $q , $document , typeaheadParser ) {
34
34
35
35
var HOT_KEYS = [ 9 , 13 , 27 , 38 , 40 ] ;
36
36
@@ -49,6 +49,8 @@ angular.module('ui.bootstrap.typeahead', [])
49
49
//should it restrict model values to the ones selected from the popup only?
50
50
var isEditable = originalScope . $eval ( attrs . typeaheadEditable ) !== false ;
51
51
52
+ var isLoadingSetter = $parse ( attrs . typeaheadLoading ) . assign || angular . noop ;
53
+
52
54
//create a child scope for the typeahead directive so we are not polluting original scope
53
55
//with typeahead-specific data (matches, query etc.)
54
56
var scope = originalScope . $new ( ) ;
@@ -64,6 +66,7 @@ angular.module('ui.bootstrap.typeahead', [])
64
66
var getMatchesAsync = function ( inputValue ) {
65
67
66
68
var locals = { $viewValue : inputValue } ;
69
+ isLoadingSetter ( originalScope , true ) ;
67
70
$q . when ( parserResult . source ( scope , locals ) ) . then ( function ( matches ) {
68
71
69
72
//it might happen that several async queries were in progress if a user were typing fast
@@ -88,8 +91,12 @@ angular.module('ui.bootstrap.typeahead', [])
88
91
} else {
89
92
resetMatches ( ) ;
90
93
}
94
+ isLoadingSetter ( originalScope , false ) ;
91
95
}
92
- } , resetMatches ) ;
96
+ } , function ( ) {
97
+ resetMatches ( ) ;
98
+ isLoadingSetter ( originalScope , false ) ;
99
+ } ) ;
93
100
} ;
94
101
95
102
resetMatches ( ) ;
0 commit comments