TypeError: this.userService.login is not a function


#1

Greetings everyone.

I’m working through the Groceries tutorial in the NativeScript playground. I’ve come to Step 12, Section f at the bottom of that step. When I try to activate the login() function which is attached to one of the buttons on the main screen, the NativeScript Preview app throws an error - ERROR: ERROR TypeError: this.userService.login is not a function. (In ‘this.userService.login(this.user)’, ‘this.userService.login’ is undefined)

As far as I can tell, I’ve copy/paste’d the example correctly. Preview App version 1.6.0; Runtime version 3.3.0; iPhone 6 Plus; iOS version 11.1.2.

Thanks very much for any help.

Cheers,
Brian


#2

Step 12 is the “Dialog Module”. I don’t see “Section F” in that step. There’s only two sections, a and b. I’m not sure where you are at when you say “Step 12, Section F”.


#3

@OldBrian
Please click on the share button in playground and send us the URL to your playground app.
So that we can see what is going on. I could see the Step 12 Section F of Angular Groceries App.

@pentool I think you are looking at the sections of {N} Core tutorial.


#4

This is the Groceries tutorial menu which presents itself to me -

This is the URL - https://play.nativescript.org/?template=groceries-ng&tutorial=groceries-ng&id=9uf4Rx

Cheers,
Brian


#5

@OldBrian
Url - https://play.nativescript.org/?template=groceries-ng&tutorial=groceries-ng&id=9uf4Rx&v=2

It seems to be working fine now. All I did was follow step 12 again (but by copy-pasting the code from the tutorial window)
There might have been a typo in your code somewhere.

Cheers! Happy NativeScripting :slight_smile:


#6

Thanks very much for that. It’s working fine for me now also. I’d be curious where the error was located, because I was sure I copy/paste’d everything.

Cheers,
Brian


#7

I am not sure either. you might want to compare the 2 versions