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

RouterOutlet

一个占位符,Angular 会根据当前的路由器状态动态填充它。

Acts as a placeholder that Angular dynamically fills based on the current router state.

查看"说明"...

参见

Exported from

选择器

属性

属性说明
@Output('activate')
activateEvents: EventEmitter<any>
@Output('deactivate')
deactivateEvents: EventEmitter<any>
isActivated: boolean只读
component: Object只读
activatedRoute: ActivatedRoute只读
activatedRouteData: Data只读

模板变量参考手册

标识符用途
outlet#myTemplateVar="outlet"

说明

每个出口可以具有唯一的名称,该 name 由可选的 name 属性确定。该名称不能动态设置或更改。如果未设置,则默认值为 “primary”。

Each outlet can have a unique name, determined by the optional name attribute. The name cannot be set or changed dynamically. If not set, default value is "primary".

      
      <router-outlet></router-outlet>
<router-outlet name='left'></router-outlet>
<router-outlet name='right'></router-outlet>
    

命名出口可以是辅助路由的目标。辅助路由的 Route 对象具有一个 outlet 属性,用于标识目标出口:

Named outlets can be the targets of secondary routes. The Route object for a secondary route has an outlet property to identify the target outlet:

{path: <base-path>, component: <component>, outlet: <target_outlet_name>}

使用命名的出口和辅助路由,你可以在同一 RouterLink 指令中定位多个出口。

Using named outlets and secondary routes, you can target multiple outlets in the same RouterLink directive.

路由器在导航树中跟踪每个命名出口的单独分支,并在 URL 中生成该树的表示形式。辅助路由的 URL 使用以下语法同时指定主要路由和辅助路由:

The router keeps track of separate branches in a navigation tree for each named outlet and generates a representation of that tree in the URL. The URL for a secondary route uses the following syntax to specify both the primary and secondary routes at the same time:

http://base-path/primary-route-path(outlet-name:route-path)

每当新组件实例化之后,路由出口就会发出一个激活事件;在销毁时则发出取消激活的事件。

A router outlet emits an activate event when a new component is instantiated, and a deactivate event when a component is destroyed.

      
      <router-outlet
  (activate)='onActivate($event)'
  (deactivate)='onDeactivate($event)'></router-outlet>
    

方法

RouteReuseStrategy 的指示,从子树中分离开时调用

Called when the RouteReuseStrategy instructs to detach the subtree

      
      detach(): ComponentRef<any>
    
参数

没有参数。

返回值

ComponentRef<any>

RouteReuseStrategy 的指示,把以前分离的子树重新附加回来时调用

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

      
      attach(ref: ComponentRef<any>, activatedRoute: ActivatedRoute)
    
参数
ref ComponentRef
activatedRoute ActivatedRoute
      
      deactivate(): void
    
参数

没有参数。

返回值

void

      
      activateWith(activatedRoute: ActivatedRoute, resolver: ComponentFactoryResolver)
    
参数
activatedRoute ActivatedRoute
resolver ComponentFactoryResolver