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
Description
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.
- If the current behavior is a bug, please provide the steps to reproduce and if possible a minimal demo of the problem via
https://plnkr.co or similar (you can use this template as a starting point: http://plnkr.co/edit/tpl:yBpEi4).
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)