我使用material2和anular2处理了应用程序。我有这个错误“this._appRef.registerChangeDetector不是一个函数”。
小吃吧-material.html:
<button md-button (click)="openSnackBar()">Trigger Snackbar</button>
TS功能:
import { Component} from '@angular/core';
import {MdSnackBar} from '@angular/material';
@Component({
templateUrl:'snackbar-material.html',
})
export class SnackbarOverviewComponent{
constructor(
public snackBar: MdSnackBar) {}
openSnackBar() {
this.snackBar.open("Showing Snack", "Yayyy!");
}
}
错误:
EXCEPTION: Error in ./SnackbarOverviewComponent class SnackbarOverviewComponent - inline template:0:0 caused by: this._appRef.registerChangeDetector is not a function vendor.bundle.js:61055:9
ORIGINAL EXCEPTION: this._appRef.registerChangeDetector is not a function vendor.bundle.js:61057:13
ORIGINAL STACKTRACE: vendor.bundle.js:61060:13
DomPortalHost.prototype.attachComponentPortal@http://localhost:4200/vendor.bundle.js:66657:13
BasePortalHost.prototype.attach@http://localhost:4200/vendor.bundle.js:35172:20
OverlayRef.prototype.attach@http://localhost:4200/vendor.bundle.js:66238:28
MdSnackBar.prototype._attachSnackBarContainer@http://localhost:4200/vendor.bundle.js:68168:28
MdSnackBar.prototype.openFromComponent@http://localhost:4200/vendor.bundle.js:68122:33
MdSnackBar.prototype.open@http://localhost:4200/vendor.bundle.js:68157:33
[653]/SnackbarOverviewComponent.prototype.openSnackBar@http://localhost:4200/main.bundle.js:390:9
anonymous/View_SnackbarOverviewComponent0.prototype.handleEvent_0@/MaterialAppModule/SnackbarOverviewComponent/component.ngfactory.js:56:21
DebugAppView.prototype.eventHandler/<@http://localhost:4200/vendor.bundle.js:86216:24
decoratePreventDefault/<@http://localhost:4200/vendor.bundle.js:48265:53
ZoneDelegate.prototype.invokeTask@http://localhost:4200/vendor.bundle.js:111220:21
NgZone.prototype.forkInnerZoneWithAngularBehavior/this.inner<.onInvokeTask@http://localhost:4200/vendor.bundle.js:31689:28
ZoneDelegate.prototype.invokeTask@http://localhost:4200/vendor.bundle.js:111219:21
Zone.prototype.runTask@http://localhost:4200/vendor.bundle.js:111109:28
ZoneTask/this.invoke@http://localhost:4200/vendor.bundle.js:111290:28
vendor.bundle.js:61061:13
ERROR CONTEXT: vendor.bundle.js:61064:13
Object { _view: Object, _nodeIndex: 0, _tplRow: 0, _tplCol: 0 } vendor.bundle.js:61065:13
Error: Error in ./SnackbarOverviewComponent class SnackbarOverviewComponent - inline template:0:0 caused by: this._appRef.registerChangeDetector is not a function