angular - 模块 './login/servcioprueba1.service"' 没有导出成员 'prueba'.ts(2305)
问题描述
我有 Angular 8 的服务文件
ng gs servicioprueba1
我按如下方式导入文件
见第 2 块
并在 Block 的这一行
从'./servcioprueba1.service'导入{prueba};我收到错误 << Module '"../extra/login/servcioprueba1.service"' has no export member 'prueba'.ts(2305) >>
有人知道,我怎么能解决这个错误
注意:在 angular 8 的其他项目中,代码工作正常
保护你
第 2 座
import { Component, OnInit } from '@angular/core';
import { FormBuilder, FormGroup, Validators } from '@angular/forms';
import { Router } from '@angular/router';
import { Observable } from 'rxjs';
import { prueba } from './servcioprueba1.service';
@Component({
selector: 'page-login',
templateUrl: './login.component.html',
styleUrls: ['./login.component.scss']
})
export class PageLoginComponent implements OnInit {
constructor(private authService: prueba) { }
}
解决方案
在服务所属的模块中,确保将其列为提供者
// other imports
import { prueba } from '<path_to_prueba.service.ts>';
@NgModule({
declarations: [<Name_Of_Module>],
imports: [
//...
],
providers: [
//other providers ...
prueba,
],
})
export class <Name_Of_Module> {}
然后PageLoginComponent
所属的模块也一样。
推荐阅读
- jquery - Rails jquery如何获取动态添加内容id
- java - Selenium-Java-Actions TypeError: rect is undefined
- azure-service-fabric - 分区解析在 Service Fabric 中没有意义
- github - Markdown 表未显示在 github .md 页面上
- c# - 父滚动时隐藏浮动操作按钮
- java - 在父级或祖先中找不到方法 buttonCap(View)
- ios - 如何在 TableView 中调整自定义单元格的大小?
- android - 房间查询不起作用
- android - 如何更改android studio底部导航栏上选择的图标颜色
- java - 为具有不同角半径的圆角矩形提供轮廓以在 Android 中剪辑视图