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!

Community
  • 1
  • 1
Jordi Nebot
  • 3,355
  • 3
  • 27
  • 56
  • 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. – JB Nizet Nov 03 '16 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`)? – Jordi Nebot Nov 03 '16 at 17:58
  • The most important change is the module system. I would read the section of the official angular doc, that describes them. – JB Nizet Nov 03 '16 at 19:36
  • I've also used this [guide](https://www.barbarianmeetscoding.com/blog/2016/08/13/updating-your-angular-2-app-from-rc4-to-rc5-a-practical-guide/). – Jordi Nebot Nov 03 '16 at 19:37

0 Answers0