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

ComponentFixture

Fixture for debugging and testing a component.

      
      class ComponentFixture<T> {
  constructor(componentRef: ComponentRef<T>, ngZone: NgZone, _autoDetect: boolean)
  debugElement: DebugElement
  componentInstance: T
  nativeElement: any
  elementRef: ElementRef
  changeDetectorRef: ChangeDetectorRef
  componentRef: ComponentRef<T>
  ngZone: NgZone | null
  detectChanges(checkNoChanges: boolean = true): void
  checkNoChanges(): void
  autoDetectChanges(autoDetect: boolean = true)
  isStable(): boolean
  whenStable(): Promise<any>
  whenRenderingDone(): Promise<any>
  destroy(): void
}
    

构造函数

constructor(componentRef: ComponentRef<T>, ngZone: NgZone, _autoDetect: boolean)
      
      constructor(componentRef: ComponentRef<T>, ngZone: NgZone, _autoDetect: boolean)
    
参数
componentRef ComponentRef
ngZone NgZone
_autoDetect boolean

属性

属性说明
debugElement: DebugElement

The DebugElement associated with the root element of this component.

componentInstance: T

The instance of the root component class.

nativeElement: any

The native element at the root of the component.

elementRef: ElementRef

The ElementRef for the element at the root of the component.

changeDetectorRef: ChangeDetectorRef

The ChangeDetectorRef for the component

componentRef: ComponentRef<T>Declared in constructor.
ngZone: NgZone | nullDeclared in constructor.

方法

Trigger a change detection cycle for the component.

detectChanges(checkNoChanges: boolean = true): void
      
      detectChanges(checkNoChanges: boolean = true): void
    
参数
checkNoChanges boolean

可选. 默认值是 true.

返回值

void

Do a change detection run to make sure there were no changes.

checkNoChanges(): void
      
      checkNoChanges(): void
    
参数

没有参数。

返回值

void

Set whether the fixture should autodetect changes.

autoDetectChanges(autoDetect: boolean = true)
      
      autoDetectChanges(autoDetect: boolean = true)
    
参数
autoDetect boolean

可选. 默认值是 true.

Also runs detectChanges once so that any existing change is detected.

Return whether the fixture is currently stable or has async tasks that have not been completed yet.

isStable(): boolean
      
      isStable(): boolean
    
参数

没有参数。

返回值

boolean

Get a promise that resolves when the fixture is stable.

whenStable(): Promise<any>
      
      whenStable(): Promise<any>
    
参数

没有参数。

返回值

Promise<any>

This can be used to resume testing after events have triggered asynchronous activity or asynchronous change detection.

Get a promise that resolves when the ui state is stable following animations.

whenRenderingDone(): Promise<any>
      
      whenRenderingDone(): Promise<any>
    
参数

没有参数。

返回值

Promise<any>

Trigger component destruction.

destroy(): void
      
      destroy(): void
    
参数

没有参数。

返回值

void