Skip to content
This repository was archived by the owner on Apr 12, 2024. It is now read-only.
This repository was archived by the owner on Apr 12, 2024. It is now read-only.

Properties set before constructor is called when using bindToController #14206

Closed
@suedama1756

Description

@suedama1756

Note: for support questions, please use one of these channels: https://github.com/angular/angular.js/blob/master/CONTRIBUTING.md#question. This repository's issues are reserved for feature requests and bug reports.

  • Do you want to request a feature or report a bug?

BUG

  • What is the current behavior?

When using bindToController properties are being set before the constructor is invoked.

bindToController: {
    min: '@',
}

class MyController {
  private _min : number; 
  constructor() {
     this._min = 0;
  }

  get min() {
    return this._min;
  }

  set min(value : number) {
     this._min = value;
  } 
}
  • What is the expected behavior?

Constructor should be called before properties are set.

  • What is the motivation / use case for changing the behavior?

Behaviour in properties setters that rely on values initialized in the constructor fail.

  • Which version of Angular, and which browser and OS does this issue affect? Did this work in previous
    versions of Angular? Please also test with the latest stable and snapshot versions.

Windows 7, TypeScript 1.8.2, chrome 49.0.2623.87, Angular 1.5.0

  • Other information (e.g. detailed explanation, stacktraces, related issues, suggestions how to fix)

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions