angular2 step by step #3 - hello world routing

routing is critical for every web framework architecture.  ASP.net / JSP have server side routing built-in, dealing with http modules and handler. Angular changes from server side architecture to client side, with the routing as well. Angular2 did it one step further

official Angular2 Routing here: https://angular.io/docs/ts/latest/guide/router.html. following is quick view on how routing works in angular2.

1. setup base for the client side app.
client visit "index.html" and load it into browser,  all the subsequent request routing is based on this root. treat this as a starting baseline for the client app.

    src/index.html (base-href) => <head> => <base href="http://www.likecs.com/"> 

2. create new component.

    ng g component home

3. import routing module into application & configure routing

    app.module.ts =>  import { RouterModuleRouterfrom \'@angular/router\';

  imports: [

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:https://www.heiqu.com/zzzxpz.html