craftpip / angular-confirm

A multipurpose plugin for alert, confirm & dialog for angular1
http://craftpip.github.io/angular-confirm/
MIT License
115 stars 20 forks source link

Some scope watch may caused angular dirty check goes wrong. #2

Closed Woodu closed 7 years ago

Woodu commented 7 years ago

In Line 481:

 _bindEvents: function () {
                    var that = this;
                    this._scope.$watch('[ngc.alignMiddle, ngc.offsetTop, ngc.offsetBottom]', function () {
                        that.setDialogCenter('bindEvents');
                    });

due to angular offical document (https://docs.angularjs.org/error/$rootScope/infdig ),those code may caused dirty check error. I modified to this.

_bindEvents: function () {
          var that = this;
          var boxSets = [this._scope.ngc.alignMiddle, this._scope.ngc.offsetTop, this._scope.ngc.offsetBottom];
          this._scope.$watch(boxSets, function () {
            that.setDialogCenter('bindEvents');
          });
craftpip commented 7 years ago

Thanks for this, will make the changes soon

raykin commented 7 years ago

same error here, woodu's solution works

craftpip commented 7 years ago

from v1.1.0 ngConfirm wont use scope for internal operations, this caused problems in memory leaks and circular references.

previous code is completely removed.