Skip to content
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

Accept HTML only custom element in moduleId RouteConfig #49

Closed
AbraaoAlves opened this issue Dec 23, 2016 · 8 comments
Closed

Accept HTML only custom element in moduleId RouteConfig #49

AbraaoAlves opened this issue Dec 23, 2016 · 8 comments

Comments

@AbraaoAlves
Copy link
Contributor

I'm submitting a feature request

Expected/desired behavior:

  • What is the expected behavior?
    The moduleId should work not just ViewModels, but also HTML only custom elements.

Like tag <require from="my-component.html">, that accept viewModels and Views, moduleId in RouteConfig should accept string like this:

    config.map([
       { route: ['', '/'], moduleId: 'no-selection.html',  title: 'Select'},
       { route: 'contacts/:id',  moduleId: 'contact-detail',  name:'contacts'}  
    ]);

What is the motivation / use case for changing the behavior?
Less is MORE. Write empty class to just route works, should not be the Aurelia way.

@EisenbergEffect
Copy link
Contributor

Closing this as a duplicate. We have a feature tracked to enable "view only" routes. Thanks!

@AbraaoAlves
Copy link
Contributor Author

@EisenbergEffect any link?

@AbraaoAlves
Copy link
Contributor Author

AbraaoAlves commented Dec 23, 2016

I don't find any feature like this. Yes is there #25, but is about layout view-only no page view-only.

Take app-contacts app and put this code on app.js:

config.map([
   { route: ['', '/'], **moduleId: 'no-selection.html',**  title: 'Select'},
   { route: 'contacts/:id',  moduleId: 'contact-detail',  name:'contacts'}  
]);

The aurelia-template-route don't work with moduleId path. But if I make little change on route-loader.js ... It works, not more empty class!!

I want know if a way to do this, without change source code?

@carusology
Copy link

I also ran into this limitation. As far I as I can tell, we are required to create an empty view-model to back the view. @EisenbergEffect, can you give us a link to whatever issue is tracking this feature request? The issue @AbraaoAlves referenced, #25, does not appear to be related.

@EisenbergEffect
Copy link
Contributor

I thought we had a feature for this somewhere. Perhaps, I was wrong? I'll re-open this.

@carusology
Copy link

carusology commented Jan 23, 2017

@EisenbergEffect k, thanks.

When I attempted to get this to work within the current architecture, I used the my-view.html style of syntax that is referenced in Aurelia Hub for HTML-Only custom elements, but put it in my route config, like so:

export class App {

  configureRouter(config, router) {
    this.router = router;
    config.title = 'Aurelia';

    config.map([
      { route: ['', 'home'], name: 'home', moduleId: './my-view.html' }
    ]);
  }
}

However, this results in the error message "Uncaught (in promise) Error: Cannot find module './my-view'." from webpack. Once I added a blank view-model (which, to be fair, is a single line of code) and removed the *.html suffix in the route config it worked fine.

// filename: my-view.ts
export default class MyView {}

This *.html suffix is the exact approach @AbraaoAlves suggested in his pull request. Did you follow the same deductive path, @AbraaoAlves?

Unfortunately, I keep expecting custom elements and views to behave in a similar fashion, but that expectation is consistently wrong.

@AbraaoAlves
Copy link
Contributor Author

That's it @carusology, clear like water.
Thanks!

@gheoan
Copy link

gheoan commented Oct 22, 2017

@EisenbergEffect, @AbraaoAlves I think this can be closed since #50 was merged.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants