[英]Cannot find module generated with “Ionic g provider”
I generated a provider in Ionic CLI as below: 我在Ionic CLI中生成了一个提供程序,如下所示:
C:\\Ionic\\myApp>ionic g provider DataService C:\\ Ionic \\ myApp> ionic g提供程序DataService
[OK] Generated a provider named DataService! [确定]生成了一个名为DataService的提供程序!
However, when I try to import that in app.module.ts as below: 但是,当我尝试将其导入app.module.ts中时,如下所示:
import { HttpModule } from '@angular/http'; import { DataService } from '../providers/data-service';
I get an error saying 我说错了
Cannot find module '../providers/data-service' 找不到模块“ ../providers/data-service”
app.module.ts is located @ src/app/app.module.ts and the path ' ../providers/data-service ' to data service is correct from its location. app.module.ts位于src / app / app.module.ts上 ,数据服务的路径“ ../providers/data-service ”从其位置是正确的。
Can anyone please suggest where am I going wrong here? 有人可以建议我在哪里错吗?
I am trying to build the exercise given in : https://www.djamware.com/post/58fdf9f080aca7414e78a63a/ionic-3-and-angular-4-multi-level-accordion-menu-example 我正在尝试构建以下练习: https : //www.djamware.com/post/58fdf9f080aca7414e78a63a/ionic-3-and-angular-4-multi-level-accordion-menu-example
The path should include the file name as well without .ts
: 该路径也应包含文件名,而不包含.ts
:
import { DataServiceProvider } from '../providers/data-service/data-service';
But normally ionic g
does this for you, unless you used the --no-module
option. 但是通常ionic g
会为您完成此操作,除非您使用--no-module
选项。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.