繁体   English   中英

ModuleNotFoundError(在路径中找不到模块:“./translate.service”相对于“/src/app/app.component.ts”)

[英]ModuleNotFoundError (Could not find module in path: './translate.service' relative to '/src/app/app.component.ts')

我是 angular 的新手,想构建一个翻译应用程序,但遇到了这个错误。 代码如下:

 import { Component } from "@angular/core";
    import { TranslateService } from "./translate.service";
    
    @Component({
      selector: "app-root",
      templateUrl: "./app.component.html",
      styleUrls: ["./app.component.css"]
    })
    export class AppComponent {
    
      text: string;
      translatedText: string;
    
      constructor(private translateService: TranslateService) {};
    
      submit(){
        this.translateService.translate(this.text).subscribe((result)=>{
          this.translatedText = result;
        })
      }
    }

您必须在“导入”列表中的 app.module.ts 中导入TranslateModule 在官方文档中,您可以找到您需要的任何其他信息。

https://github.com/ngx-translate/core

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM