Click here to Skip to main content
15,881,248 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello, I have been encountering this error below and i haven't gotten a solution.
I would appreciate it if a solution is being rendered.
Thanks.

The below error occurs after i exported a phone number object and assigned a data type of number in my app.service.ts and imported it in my app.page.ts

export class AppPage implements OnInit {

user: user = {

PhoneNumber: number,

}


'number' only refers to a type, but is being used as a value here.


Or am i doing the wrong thing?

What I have tried:

i currently do not have any idea at this point.
Posted
Updated 18-Jun-19 0:57am

1 solution

What your code currently tries to do, is creating a user property of the AppPage class of type user, and the PhoneNumber property of user gets set to a value - however, the 'value' in this case is number, which is a type and not a value.

How to fix it, depends on what you want to do. If you want to define PhoneNumber as a property of user with number as datatype, then define user in an external class:
TypeScript
class user {
    PhoneNumber: number
}
If you already have such a class and want to create a specific instance of it, then provide an actual value for PhoneNumber on creation of the user instance.
 
Share this answer
 
Comments
Eric Tade 21-Jun-19 10:41am    
Thank you so much!

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900