Why do we call $ timeout without a delay argument.

I'm trying to read some angularjs code There is a point at which $ timeout is called without a delay parameter.

dataBinding: () => {
            this.$timeout(() => {
                this.selectedRow = null;
            });
        },

What is the purpose of this?

+4
source share
2 answers

In this context (angular.js), this is a workaround - when you just want to defer your action until the next angular digest cycle (and be sure that this does not happen in the current digest cycle).

If this is your case, you are better off using it $scope.$evalAsync()for this purpose. See http://www.bennadel.com/blog/2605-scope-evalasync-vs-timeout-in-angularjs.htm

+3
source

If you do not set the delay value, it will be set to 0.

; . this

0?

0

Source: https://habr.com/ru/post/1620533/


All Articles