i want to use $watch for the ng-model in input, DOESNT WORK
See original GitHub issuei want to use $watch for the ng-model in input, so that once ng-model gets changed, I can use that to move my map around?
// when autolocation search changes
$scope.$watch('autolocation', function(){
console.log("changed location!");
})
<input type="text" g-places-autocomplete ng-model="autolocation" options="autocompleteOptions" class="map-controls" placeholder="Search Location"/>
Issue Analytics
- State:
- Created 8 years ago
- Comments:5
Top Results From Across the Web
angularjs - $watch ngModel not firing - Stack Overflow
I have made a directive to handle file uploads, and it works when uploading files, but not so good when preloading data because...
Read more >ngModel - AngularJS: API
ngModel watches the model by reference, not value. This is important to know when binding inputs to models that are objects (e.g. ·...
Read more >Difference between (change) and (ngModelChange) in Angular
Using (ngModelChange) essentially is listening to the input event, and setting the model if a user types, pastes or changes the input's value....
Read more >I'd like to be able to use ngModel without specifying a name
I think this is a valid case, specially when I don't want to have the form.value to contain the value specified by [(ngModel)]....
Read more >48 answers on StackOverflow to the most popular Angular ...
We have to import OnInit in order to use like this (actually ... Can't bind to 'ngModel' since it isn't a known property...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
try:
controller:
html:
But it will trigger on each change made on search input.
If you want to receive when a new location is selected, you could use:
@Diones Both of your solutions worked great, for the first solution i had to make small correction like below
if(typeof newValue == "object"){
this will prevent trigger on each change made on search input