小编Bha*_*vin的帖子

无法解析rxjs

编译失败.

./src/app/hero.service.ts找不到模块:错误:无法解析'C:\ Users\Admin\angular\myheroes\src\app'中的'rxjs/Observable/of'

@ ./src/app/hero.service.ts 13:11-40 
@ ./src/app/app.module.ts 
@ ./src/main.ts 
@ multi webpack-dev-server/client?http://0.0.0.0:0 ./src/main.ts
Run Code Online (Sandbox Code Playgroud)

我的代码为hero.service.ts

import { Injectable } from '@angular/core';
import { Observable } from 'rxjs';
import { of } from 'rxjs/Observable/of';
import { Hero } from './hero';
import { HEROES } from './mock-heroes';
import { MessageService } from './message.service';

@Injectable()
export class HeroService {

   constructor(private messageService: MessageService) { }

  getHeroes(): Observable<Hero[]>

  {
    // todo: send the message _after_fetching the heroes
    this.messageService.add('HeroService: fetched heroes');
    return of (HEROES);
  }
}
Run Code Online (Sandbox Code Playgroud)

npm node-modules angular

17
推荐指数
4
解决办法
6万
查看次数

标签 统计

angular ×1

node-modules ×1

npm ×1