Hi Marc,

This shouldn't be hard, at least not on the Angular side. Let's say you 
have root-level routing pointing to your blog module:

{ path: 'blog', loadChildren: './blog/blog.module#BlogModule' }


Now this blog module has two routes: "*list articles*" and "*display single 
article*".

{ path: 'all', component: AllArticlesComponent },
{ path: ':prettyUrl', component: SingleArticleComponent },


Notice the "pretty url" part of your requirement? It's probably the same as 
you had now, except it's named *prettyUrl* instead of *id*.

Now we wanna look into this "*display single article*" component. Anything 
special it does it get the *prettyUrl* parameter from the route and load 
the appropriate component:

class SingleArticleComponent implements OnInit {
  
  article: Article;
  
  constructor(private route: ActivatedRoute,
              private blogService: BlogService) {}
  
  ngOnInit() {
    this.route.params.subscribe((params: any) => {
      const articleUrl = params.prettyUrl;
      this.blogService.getArticleByBetterUrl(articleUrl)
        .subscribe(article => this.article = article);
    })
  }
}


So all that is left is this blog service implementation. How you load the 
article by *prettyUrl *depends on where you save it (e.g. JSON, REST API, 
CMS, Firebase etc).

Hope that helps.




-- 
You received this message because you are subscribed to the Google Groups 
"Angular and AngularJS discussion" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/angular.
For more options, visit https://groups.google.com/d/optout.

Reply via email to