Error: Can't resolve 'rxjs/add/operator/filter' in 'J:\auction\src\app\content'
来源:3-9 改造股票管理应用

慕粉4270219
2018-11-17
![图片描述]引入 了包为什么还报错,引的不对吗?(http://img.mukewang.com/szimg/5befc1b30001581e03890334.jpg)
3回答
-
这个问题有人回答了
https://coding.imooc.com/learn/questiondetail/68790.html
这样写
//引入
import { filter} from 'rxjs/operators';
//构造器
constructor(public router: Router) {
this.router.events.pipe(
filter((event: Event) => event instanceof NavigationEnd)
).subscribe((event: NavigationEnd) => {
if (event.url === '/dashboard') {
this.pageTitle = '这里是首页';
this.pageDesc = '';
} else if (event.url.startsWith('/stock')) {
this.pageTitle = '股票信息管理';
this.pageDesc = '进行股票信息基本增删改查';
}
});
}012018-11-24 -
wtxy
2018-11-20
import { Component, OnInit } from '@angular/core'; import {filter, map} from 'rxjs/operators'; import {Router, NavigationEnd} from "@angular/router"; @Component({ selector: 'app-content', templateUrl: './content.component.html', styleUrls: ['./content.component.css'] }) export class ContentComponent implements OnInit { pageTitle = ''; pageDesc = ''; constructor(public router: Router) { //新版本rxjs filter要放在pipe中用 const filterRouter = router.events.pipe( filter(event => event instanceof NavigationEnd) ); filterRouter.subscribe((event: NavigationEnd) => { if (event.url == '/dashboard') { this.pageTitle = '这里是首页'; this.pageDesc = '首页描述'; } else if (event.url.startsWith('/stock')) { this.pageTitle = '股票信息管理'; this.pageDesc = '股票信息基本增删改查'; } }) } ngOnInit() { } }
00 -
wtxy
2018-11-18
你搜索一下问题:
引入 rxjs 失败
有同学问过,这是新版本rxjs用法不同的问题,下面是炫酷同学的回到,亲试有效,
以后这课程遇到问题,可以尝试搜索以前同学的问题,一般你遇到的很可能以前就有人遇到了。。。
good luck
012018-11-20
相似问题