0

I'm building a custom CMS with Angular2 and I have two types of posts (let's call them typeA and typeB) that are identical except for this type property.

I'd like to reuse my PostListComponent and PostEditorComponent for both types but those having a different URL.

I was thinking on adding to my RouteDefinition[] (I'm still using 2.0.0-rc.2 with @angular/router-deprecated):

{
    path      : '/admin/type-a',
    name      : 'Type A Post List',
    component : PostListComponent,
    arguments : { 'type' : 'typeA' }
}, {
    path      : '/admin/type-b',
    name      : 'Type B Post List',
    component : PostListComponent,
    arguments : { 'type' : 'typeB' }
}

But I can't find any documentation on how to pass this default argument to a Component. On SO I've just found this related answer, but it's not the same issue and I wouldn't like to be using a workaround like that.

Any hint will be much appreciated!

4
  • Finding documentation on an obsolete, RC version is of course harder than finding it on the final, current version. The new, final router allows specifying data on a route. My hint is: migrate to the final version. The sooner you do it, the less work it will require. Commented Nov 3, 2016 at 17:40
  • Thanks @JBNizet. Do you know any good resources/guides for upgrading from 2.0.0-rc.2 to the current release (2.1.1 or 2.1.2)? Commented Nov 3, 2016 at 17:58
  • The most important change is the module system. I would read the section of the official angular doc, that describes them. Commented Nov 3, 2016 at 19:36
  • I've also used this guide. Commented Nov 3, 2016 at 19:37

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.