在 NativeScript 中找不到服务 Angular

Service not found in NativeScript Angular

我是 Angular nativescript 的新手,我在我的原生 angular 应用程序中使用 "ng generate service" 命令创建了一个服务,但是在导入服务时我收到模块错误找不到

app.module.ts

import { NgModule, NO_ERRORS_SCHEMA } from "@angular/core";
import { NativeScriptModule, NativeScriptHttpClientModule } from "@nativescript/angular";

import { AppRoutingModule } from "./app-routing.module";
import { AppComponent } from "./app.component";
import { LoginComponent } from './components/login/login.component';

@NgModule({
    bootstrap: [
        AppComponent
    ],
    imports: [
        NativeScriptModule,
        AppRoutingModule,
        NativeScriptHttpClientModule
    ],
    declarations: [
        AppComponent,
        LoginComponent,
    ],
    providers: [],
    schemas: [
        NO_ERRORS_SCHEMA
    ]
})
/*
Pass your application module to the bootstrapModule function located in main.ts to start your app
*/
export class AppModule { }

ApiBackRequestService.ts

import { Injectable } from '@angular/core';
import { HttpClient, HttpHeaders, HttpParams } from '@angular/common/http';
import { Observable, throwError } from 'rxjs';
import { catchError } from 'rxjs/operators';
import { environment } from '../environments/environment';

@Injectable({
    providedIn: 'root'
})
export class ApiBackRequestService {

    constructor(
        private http: HttpClient) {
    }

}

Login.component.ts

import { Component, OnInit } from '@angular/core';
import { ApiBackRequestService } from 'src/app/services/api-back-request.service';

@Component({
    selector: 'ns-login',
    templateUrl: './login.component.html',
    styleUrls: ['./login.component.css']
})
export class LoginComponent implements OnInit {

    pokemon = [];

    constructor(private api: ApiBackRequestService) { }

    ngOnInit(): void {

    }
}

谢谢

是代码共享项目吗?在 Login.component.ts 文件中,只需在 src.

之前添加 @

改变

import { ApiBackRequestService } from 'src/app/services/api-back-request.service';

import { ApiBackRequestService } from '@src/app/services/api-back-request.service';

这解决了我的问题

import { ApiBackRequestService } from '../../services/api-back-request.service';