Issue
I was trying the example on https://sniederm.wordpress.com/2017/04/12/tutorial-ng2-rest-service/ and in step 2, in "user.service.ts" file I am getting " cannot find module 'app/models/user' " error on the
import { User } from "app/models/user";
line. I tried couple of things that I can find on web, such as replacing the "app" with "." in "app/models/user" but it did not work.
In the tutorial it says "we will create a class User and place it in a file called user.ts within the „to-be-created“ subfolder app/models." I am new to angular so at first I created this folder manually (right click->new folder) but then after I get the error, I created models folder with ng generate module models prompt. But still I get the error. The user.ts file is in models folder. Can somebody help me with this, please?
Solution
Assuming that your files structure is as below:
|app
|models
|user.ts
|services
|user.service.ts
Your import should be:
import { User } from "../models/user";
Answered By - Observablerxjs
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.