## ActivatedRouteSnapshot
包含當前插座中加載組件某一特定時間路由信息。`ActivatedRouteSnapshot`同樣可以用來遍歷路由器狀態樹。
### 如何使用
```typescript
@Component({templateUrl:'./my-component.html'})
class MyComponent {
constructor(route: ActivatedRoute) {
const id: string = route.snapshot.params.id;
const url: string = route.snapshot.url.join('');
const user = route.snapshot.data.user;
}
}
```
### 接口定義
```typescript
interface ActivatedRouteSnapshot {
url : UrlSegment[]
params : Params
queryParams : Params
fragment : string
data : Data
outlet : string
component : Type<any>|string
routeConfig : Route
root : ActivatedRouteSnapshot
parent : ActivatedRouteSnapshot
firstChild : ActivatedRouteSnapshot
children : ActivatedRouteSnapshot[]
pathFromRoot : ActivatedRouteSnapshot[]
toString() : string
}
```
### 屬性
- snapshot : `ActivatedRouteSnapshot` 當前路由快照
- url : `Observable<urlsegment[]>` 當前路由匹配的URL片段。
- params : `Observable<Params>` 當前路由的矩陣參數
- queryParams : `Observable<Params>` 所有路由共享的查詢參數
- fragment : `Observable<string>` 所有路由共享的URL片段
- data :` Observable<Data>` 當前路由的靜態或者動態解析的數據。
- outlet: `string` 當前路由插座的名稱。一個常量值。
- component : `Type<any>`|`string` 路由對應的組件。一個常量值。
- routeConfig : `Route` 當前路由狀態樹的根節點
- root : `ActivatedRoute` 根路由
- parent : `ActivatedRoute` 當前路由在狀態樹中的父節點
- firstChild: `ActivatedRoute` 當前路由的第一個子節點
- children : `ActivatedRoute` 當前路由在路由狀態樹中的所有子節點
- pathFromRoot : `ActivatedRoute` 根節點到當前節點的路徑
- toString() : `string`
- 說明
- angular 1.x
- ngModelController
- ngOptions
- ngModelOptions
- lifecycle
- directive
- angular 2
- @angular/forms
- 類
- AbstractControl
- AbstractControlDirective
- AbstractFormGroupDirective
- FormControl
- FormArray
- FormBuilder
- FormGroup
- NgControl
- 接口
- controlValueAccessor
- 指令
- DefaultValueAccessor
- Angular 2 生命周期
- OnInit
- DoCheck
- @angular/router
- 配置
- Routes
- 指令
- RouterOutlet
- RouterLink
- 接口
- ActivatedRoute
- UrlTree
- NavigationExtras
- ActivatedRouteSnapshot
- RouterStateSnapshot
- 類
- UrlSegment
- UrlSegmentGroup
- UrlSerializer
- DefaultUrlSerializer
- Router
- bug記得
- @angular/http
- 類
- Http
- Body
- Response
- ResponseOptions
- Header
- Request
- RequestOptions
- URLSearchParams
- @angular/core
- decorator
- Component-decorator
- animation
- DI
- linker
- TemplateRef
- ElementRef
- EmbeddedViewRef
- ViewRef
- ViewContainerRef
- Query
- ComponentFactory
- ComponentRef
- Renderer
- change_detection
- KeyValueDiffers
- IterableDiffers
- ChangeDetectorRef
- ChangeDetectionStrategy
- Zone
- ngZone
- @angular/common
- 指令
- NgTemplateOutlet
- QueryList
- bootstrap4
- card
- form
- 重點關注博客
- 學習過的文章
- 筆記
- Angular 2 雙向綁定
- 將字符串解析成DOM
- rx相關
- operators
- combineLatest
- combineAll
- concat(All, Map, *MapTo)
- 背壓(backpressure)
- js事件keycode對應表
- 裝飾器
- 有用的代碼摘錄
- 日期操作
- 數量操作
- 字符操作
- rxjs問題
- 小示例
- h5面試準備
- react
- 開發遇到的問題