You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on May 29, 2019. It is now read-only.
In the modal options, the bindToController's behavior is inconsistent with how angular controller's bindToController behaves.
In the example, the controllerAs name is "ctrl" and also bindToController set to true.
The direction of "binding" appears to be reversed. In angular, the bindToController takes the variables bound in $scope and put them INTO the controller. As a result, references to "$scope.ctrl.field" will find the fields. Referencing these fields in the html should be "ctrl.field" If the field is a simple value (like a string), binding it there will update ctrl.field (or $scope.ctrl.field).
From what i'm seeing in the code, bootstrap is doing the opposite. When bindToController is set to true, It is taking a "copy" of the fields in the controller and then pu those inside the the $scope variable. As a result, the fields actually now exists in $scope and not $scope.ctrl. The code did an angular.extend(scope, controller). Once the copy is done, the linkage will be broken on the simple fields. Also, no $scope.ctrl object is linked/created (since that is on the "else" path). This doesn't look right. Can someone clearify/verify.
Thanks.
Tony
The text was updated successfully, but these errors were encountered:
ttsuen
changed the title
modal bindToController inconsisten behavior
modal bindToController inconsistent behavior
Jul 30, 2015
In the modal options, the bindToController's behavior is inconsistent with how angular controller's bindToController behaves.
In the example, the controllerAs name is "ctrl" and also bindToController set to true.
The direction of "binding" appears to be reversed. In angular, the bindToController takes the variables bound in $scope and put them INTO the controller. As a result, references to "$scope.ctrl.field" will find the fields. Referencing these fields in the html should be "ctrl.field" If the field is a simple value (like a string), binding it there will update ctrl.field (or $scope.ctrl.field).
From what i'm seeing in the code, bootstrap is doing the opposite. When bindToController is set to true, It is taking a "copy" of the fields in the controller and then pu those inside the the $scope variable. As a result, the fields actually now exists in $scope and not $scope.ctrl. The code did an angular.extend(scope, controller). Once the copy is done, the linkage will be broken on the simple fields. Also, no $scope.ctrl object is linked/created (since that is on the "else" path). This doesn't look right. Can someone clearify/verify.
Thanks.
Tony
The text was updated successfully, but these errors were encountered: