填写这份《一分钟调查》,帮我们(开发组)做得更好!去填写Home

RouterOutletContract

An interface that defines the contract for developing a component outlet for the Router.

查看"说明"...

      
      interface RouterOutletContract {
  isActivated: boolean
  component: Object | null
  activatedRouteData: Data
  activatedRoute: ActivatedRoute | null
  activateWith(activatedRoute: ActivatedRoute, resolver: ComponentFactoryResolver): void
  deactivate(): void
  detach(): ComponentRef<unknown>
  attach(ref: ComponentRef<unknown>, activatedRoute: ActivatedRoute): void
}
    

实现类

参见

说明

An outlet acts as a placeholder that Angular dynamically fills based on the current router state.

A router outlet should register itself with the Router via ChildrenOutletContexts#onChildOutletCreated and unregister with ChildrenOutletContexts#onChildOutletDestroyed. When the Router identifies a matched Route, it looks for a registered outlet in the ChildrenOutletContexts and activates it.

属性

属性说明
isActivated: boolean

Whether the given outlet is activated.

An outlet is considered "activated" if it has an active component.

component: Object | null

The instance of the activated component or null if the outlet is not activated.

activatedRouteData: Data

The Data of the ActivatedRoute snapshot.

activatedRoute: ActivatedRoute | null

The ActivatedRoute for the outlet or null if the outlet is not activated.

方法

Called by the Router when the outlet should activate (create a component).

      
      activateWith(activatedRoute: ActivatedRoute, resolver: ComponentFactoryResolver): void
    
参数
activatedRoute ActivatedRoute
resolver ComponentFactoryResolver
返回值

void

A request to destroy the currently activated component.

      
      deactivate(): void
    
参数

没有参数。

返回值

void

When a RouteReuseStrategy indicates that an ActivatedRoute should be removed but stored for later re-use rather than destroyed, the Router will call detach instead.

Called when the RouteReuseStrategy instructs to detach the subtree.

      
      detach(): ComponentRef<unknown>
    
参数

没有参数。

返回值

ComponentRef<unknown>

This is similar to deactivate, but the activated component should not be destroyed. Instead, it is returned so that it can be reattached later via the attach method.

Called when the RouteReuseStrategy instructs to re-attach a previously detached subtree.

      
      attach(ref: ComponentRef<unknown>, activatedRoute: ActivatedRoute): void
    
参数
ref ComponentRef
activatedRoute ActivatedRoute
返回值

void