The angular routing

A core issue

    Routing to solve the core problem by establishing a corresponding relationship between the url and pages, so that different pages can not be demonstrated by the url.

  • First, when the user enters the URL on the browser, the URL acquired the Angular and generates a parse example UrlTree
  • Second, find and activate the CI instance matching UrlTree in route configuration
  • Again, create an instance for configuration items specified components
  • Finally, the assembly of components rendering the routing template <router-outlet> where the position command

Second, the angular-route or download package

  • Or by npm CNPM installation, npm / cnpm install angular-route --save 
  • The introduction of this package (route.js file)
  • Add rely ngRoute in their own module
  • Routing configuration (routing rules), the rules refer to what kind of request, to find what the controller, similar to [{url1: "", controller1}]
  • Preparation of the corresponding views and controllers

 Third, use

    

 

   

 

 

   、

 

 

    

 

Guess you like

Origin www.cnblogs.com/wangyfax/p/11645120.html