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

Popular posts from this blog

yii2 - Yii 2 Running a Cron in the basic template -

asp.net - 'System.Web.HttpContext' does not contain a definition for 'GetOwinContext' Mystery -

mercurial graft feature, can it copy? -