Skip to content
This repository has been archived by the owner on May 29, 2019. It is now read-only.

modal bindToController inconsistent behavior #4051

Closed
ttsuen opened this issue Jul 30, 2015 · 2 comments
Closed

modal bindToController inconsistent behavior #4051

ttsuen opened this issue Jul 30, 2015 · 2 comments

Comments

@ttsuen
Copy link

ttsuen commented 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

@ttsuen ttsuen changed the title modal bindToController inconsisten behavior modal bindToController inconsistent behavior Jul 30, 2015
@wesleycho
Copy link
Contributor

Seems you are correct - I will fix this shortly.

@wesleycho
Copy link
Contributor

Fix is up in #4054, will likely be merged in tomorrow and will make it in the release on Saturday or Sunday.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants