Typescript async/await doesnt update AngularJS view

前端 未结 10 501
小鲜肉
小鲜肉 2020-12-01 09:17

I\'m using Typescript 2.1(developer version) to transpile async/await to ES5.

I\'ve noticed that after I change any property which is bound to view in my async funct

10条回答
  •  無奈伤痛
    2020-12-01 09:59

    As @basarat said the native ES6 Promise doesn't know about the digest cycle.

    What you could do is let Typescript use $q service promise instead of the native ES6 promise.

    That way you won't need to invoke $scope.$apply()

    angular.module('myApp')
        .run(['$window', '$q', ($window, $q) =>  {
            $window.Promise = $q;
        }]);
    

提交回复
热议问题