【发布时间】:2018-03-04 15:27:30
【问题描述】:
我正在尝试使用 ObservableMedia。应用程序编译成功,但在浏览器控制台中我看到此错误
错误错误:没有 ObservableMedia 的提供者! 在 injectionError (core.es5.js:1169) 在 noProviderError (core.es5.js:1207)
这是我的代码
import { Component , OnInit, ViewChild} from '@angular/core';
import {Observable} from 'rxjs/Rx';
import {MediaChange, ObservableMedia} from "@angular/flex-layout";
@Component({
selector: 'app-root',
templateUrl: './app.component.html',
styleUrls: ['./app.component.css'],
})
export class AppComponent implements OnInit {
constructor(
public media: ObservableMedia) {
}
routeLinkClick() {
if (!this.media.isActive('gt-xs')) {
this.sidenav.toggle();
}
}
请帮忙。谢谢
【问题讨论】:
-
你是否将 FlexLayoutModule 导入到你的 NgModule 中?
-
谢谢它解决了这个问题。
标签: angular angular-flex-layout