Framework: Trouble exporting functions with ESNext

Created on 18 Mar 2017  路  4Comments  路  Source: aurelia/framework

Node v7.7.2
Npm v4.1.2
Webpack v2.2.1
Browser: verified in Chrome 56 and FF 50
Language: ESNext

I am having trouble getting exported functions to work as a view model for a component that gets loaded up by a router. I'm in the process of migrating things over from an older Angular 1.x project, and want to limit the changes I have to make to the code base for now (hence exporting functions rather than use classes). Here's what I have that isn't working the way I would expect (bindings not binding, and lifecycle functions not being called):

export function Home() {   
    this.message = 'hello world';
    this.attached = function () {
        console.log('home attached');
    }
}

I did try to build it up by attaching functions to the prototype, and that seemed to work ok. Is the above style not supported?

question

All 4 comments

The framework is optimized for performance in various ways that involve using the prototype.

Good to know, thank you for the quick feedback!

It would be nice if the function style is supported in aurelia for view models
+1

Was this page helpful?
0 / 5 - 0 ratings

Related issues

tallesdantas picture tallesdantas  路  7Comments

danfma picture danfma  路  5Comments

jfbaquerocelis picture jfbaquerocelis  路  3Comments

gbreeze picture gbreeze  路  4Comments

ricbermo picture ricbermo  路  5Comments