javascript - Angular ng-click: $scope variable change followed by promise prevents scope from updating -
i have ng-click
function should change button text , run asynchronous function.
template
<button ng-click="connect()">{{buttontextconnect}}</button>
connect()
$scope.connect = function() { console.log('try connecting'); $scope.buttontextconnect = 'connecting...'; thermprobe.connect().then( function() { $scope.connected = true; }, function() { $scope.connected = false; } ); }
the console.log
displayed. $scope.buttontextconnect
not update text within button however.
thermprobe.connect()
angular promise.
if comment out async call thermprobe.connect()
button text updated expected.
here working ionic play demo, works expected. button text changes when clicked , promise resolves later.
why asynchronous call prevent $scope
change updating in template?
Comments
Post a Comment