-
Notifications
You must be signed in to change notification settings - Fork 43
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Native classes controllers not working #228
Comments
Wow... I didn't expect to see some bad limitations in native classes:
so, probably proper way to inherit it from some class Controller class Main extends alight.Controller {
constructor(option) {
super(option);
this.name = 'Hello!';
}
}; Also I want to try some trick with temporary "this" for scope functions, maybe it will works... |
I think it would be proper way to instantiate controllers with |
Yes, but in this case, it's impossible to pass scope as first arguments into constructor, like it works now - broken compatibility. or "this" will not have system functions like "$watch/scan" |
In this case the better way is to use alight.Controller. As I see Scope interface is changed in v0.14 and it is not backward compatible. |
I think that controller could looks like that: class Controller {
constructor(scope, el, expr, env) {
this.$scope = scope;
this.$el = el;
this.$env = env;
this.$expr = expr;
this.$init();
scope.$watch('$destroy', this.$destroy.bind(this));
}
$init() {
}
$destroy() {
}
} |
And I think that scope should not be mixed in controller. I'd prefer to assign controller to |
There is an issue with native class controllers in Chrome. Controller like this:
and html like this:
could not be initialised due to
new
error:The text was updated successfully, but these errors were encountered: