1
votes

I generated a provider in Ionic CLI as below:

C:\Ionic\myApp>ionic g provider DataService

[OK] Generated a provider named DataService!

However, when I try to import that in app.module.ts as below:

import { HttpModule } from '@angular/http';
import { DataService } from '../providers/data-service';

I get an error saying

Cannot find module '../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.

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

1

1 Answers

2
votes

The path should include the file name as well without .ts:

import { DataServiceProvider } from '../providers/data-service/data-service';

But normally ionic g does this for you, unless you used the --no-module option.