编译失败。
./ SRC /应用/服务/ admin.service.ts 找不到模块:错误:无法解析rxjs / Rx'在&C; \ project \ test-m \ angular \ src \ app \ services'
的package.json " rxjs":" ^ 6.0.0",
答案 0 :(得分:1)
使用
import { Observable } from 'rxjs';
代替
import { Observable } from 'rxjs/Rx';
答案 1 :(得分:-2)
我解决了这个问题
从' @ angular / common / http'中导入{HttpClientModule};
进口:[
HttpClientModule,
],
从' @ angular / common / http'中导入{HttpClient,HttpHeaders};
从&rxjs /运算符';
导入{map}构造函数(私有http:HttpClient){}
getlogin(username: string, password: string) {
return this.http.post('http://localhost:3000/auth/login', { username: username, password: password })
.pipe(map(user => {
return user;
}));
}
this.adminService.getlogin(this.login.email,this.login.password)
.pipe(first())
.subscribe(
data => {
console.log(data)
},
error => {
console.log(error)
});