Click here to Skip to main content
14,336,156 members
Rate this:
Please Sign up or sign in to vote.
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

Rate this:
Please Sign up or sign in to vote.

Solution 1

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:
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.
   
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)

  Print Answers RSS
Top Experts
Last 24hrsThis month



CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100