-
Notifications
You must be signed in to change notification settings - Fork 25.8k
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
Constructor function syntax not working for non-bootstrap components #10545
Comments
To be clear, this is for apps written in JS using the DSL not TS, right? |
@wardbell correct. |
A temporary work-around for this is to give the constructor function a name. For example, changing (function(app) {
app.HeroComponent =
ng.core.Component({
selector: 'my-hero',
template: 'Harry McHeroface'
})
.Class({
constructor: function HeroComponent() {}
});
})(window.app || (window.app = {})); is a work-around for this issue. The name doesn't have to match the name of the component but the generated code is easier to grok if it is. |
This issue has been automatically locked due to inactivity. Read more about our automatic conversation locking policy. This action has been performed automatically by a bot. |
I'm submitting a ... (check one with "x")
Current behavior
When adding a component to the NgModule declaration array, if that component's constructor is a function (
constructor: function() {}
), the component is not added to the module.Everything is fine if the array notation for the constructor is used though (
constructor: [function() {}]
).Expected/desired behavior
Using a function as a constructor should be supported.
Reproduction of the problem
http://plnkr.co/edit/kuz9JlBLWUXaUDWtCn0s?p=preview (edited)
The only difference between
HeroComponent
andVillainComponent
is how the constructors are declared, butHeroComponent
does not show.What is the motivation / use case for changing the behavior?
A function was a supported way of declaring a component constructor in RC4, and it still works for bootstrap components.
Please tell us about your environment:
The text was updated successfully, but these errors were encountered: