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

ChildrenOutletContexts

存储关于子级(=嵌套)RouterOutlet 的上下文信息。

Store contextual information about the children (= nested) RouterOutlet

      
      class ChildrenOutletContexts {
  onChildOutletCreated(childName: string, outlet: RouterOutlet): void
  onChildOutletDestroyed(childName: string): void
  onOutletDeactivated(): Map<string, OutletContext>
  onOutletReAttached(contexts: Map<string, OutletContext>)
  getOrCreateContext(childName: string): OutletContext
  getContext(childName: string): OutletContext | null
}
    

方法

实例化 RouterOutlet 指令时调用。

Called when a RouterOutlet directive is instantiated

onChildOutletCreated(childName: string, outlet: RouterOutlet): void
      
      onChildOutletCreated(childName: string, outlet: RouterOutlet): void
    
参数
childName string
outlet RouterOutlet
返回值

void

RouterOutlet 指令被销毁时调用。我们需要保留上下文,因为此出口可能在 NgIf 内部被销毁,并可能在以后重新创建。

Called when a RouterOutlet directive is destroyed. We need to keep the context as the outlet could be destroyed inside a NgIf and might be re-created later.

onChildOutletDestroyed(childName: string): void
      
      onChildOutletDestroyed(childName: string): void
    
参数
childName string
返回值

void

在导航期间停用相应的路由时调用。由于组件被销毁,所有子出口也都被销毁了。

Called when the corresponding route is deactivated during navigation. Because the component get destroyed, all children outlet are destroyed.

onOutletDeactivated(): Map<string, OutletContext>
      
      onOutletDeactivated(): Map<string, OutletContext>
    
参数

没有参数。

返回值

Map<string, OutletContext>

onOutletReAttached(contexts: Map<string, OutletContext>)
      
      onOutletReAttached(contexts: Map<string, OutletContext>)
    
参数
contexts Map
getOrCreateContext(childName: string): OutletContext
      
      getOrCreateContext(childName: string): OutletContext
    
参数
childName string
返回值

OutletContext

getContext(childName: string): OutletContext | null
      
      getContext(childName: string): OutletContext | null
    
参数
childName string
返回值

OutletContext | null