jquery - AngularJS $scope won't update when ng-model is updated -


i have following html

<input id="zoom" name="zoom" style="width:100px" type="text" ng-model="user.zoomlvl"> 

when run below updates above html input field

google.maps.event.addlistener(map, 'zoom_changed', function() {     mapzoom(); }); function mapzoom(){     valzoom = map.getzoom();     $('#zoom').val(valzoom); } 

but $scope.user.zoomlvl still not update when zoom_changed has updated input field.

if you're using events not part of angular (e.g. zoom_changed), don't run $scope.$apply() @ end ng-click would. that's why $scope not updated. therefore, in event need add $scope.$apply()

function mapzoom(){     valzoom = map.getzoom();     //$('#zoom').val(valzoom);     // better     $scope.user.zoom1v1 = valzoom     $scope.$apply(); } 

Comments

Popular posts from this blog

java - WrongTypeOfReturnValue exception thrown when unit testing using mockito -

php - Magento - Deleted Base url key -

android - How to disable Button if EditText is empty ? -