angular 學習記錄

3章3小結 路由傳參的3種方式和路由快照,訂閱,html

@相同路由的跳轉(只是參數不一樣),並不會觸發Oninit ,由於沒有從新建立component編程

@子路由component

//此種狀況 是當我路由地址是 ../Home 主頁面展現 HomeComponent ,HomeComponent中html <router-outlet></router-outlet> 展現AComponentrouter

//就是<router-outlet></router-outlet> 路由插座的嵌套htm

{ path:'Home' , component:HomeComponent接口

 children:[路由

    {path:'' ,component:AComponent }, input

  {path:'xx' ,component:xxComponent }it

]io

}

@輔助路由

 

@路由守衛  就是路由上面的攔截器  CanActivate ,CanDeactivate,Resolve 他們都是接口 

CanActivate 處理導航倒某路由的狀況,此處能夠判斷用戶是否有權限 進入路由指定的頁面,

CanDeactivate 處理離開某路由的狀況,

Resolve 在路由激活以前獲取路由信息

export class PermissionCheck implements CanActivate{

  canActivate(){ return true;}

}

@須要在配置路由的地方指定路由守衛  {path:'xx' ,component:xxComponent ,avtivates:[PermissionCheck ]}

 

@依賴注入 是單例 

 

 

模板本地變量 

<input #myinput   (click)="myclick(myinput.value)" >

#myinput 聲明變量  此事myinput 就是 input document

響應式編程

相關文章
相關標籤/搜索