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

modal bindToController inconsistent behavior #4051

Closed
@ttsuen

Description

@ttsuen

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions