Hawk
Posts: 0
Joined: Mon Aug 04, 2014 11:23 am

AngularJS: How to get the value of selected list item

Hello,

I have a list linked to a collection. I want on list item click, to read the value of that particular list item to a variable.

Say, I have a model premessage/pre, that has a variable of the type String called prefrom/pre

I want on list item click, to update premessage.from/pre with the value of that list item.

I tried on list item properties to add the following:
preng-model : message.from/pre

but that did not work. It works for input fields though

Thanks in advance

Serhii Kulibaba
Posts: 150
Joined: Tue Aug 27, 2013 1:47 pm

AngularJS: How to get the value of selected list item

Hello,

Please clarify, did you create a scope variable with a type=message on this page?

Hawk
Posts: 0
Joined: Mon Aug 04, 2014 11:23 am

AngularJS: How to get the value of selected list item

Hi Sergiy,

Yes, there is a scope variable called toName of the type codemessage/code:

Image

From the screenshot below, I am following you Chat App tutorial with few tweaks:
I have list of people the user could chat with. And I want upon clicking on any of them, to navigate to the chat page.

Image

In the chat page, I sent the value codetoName/code along with the message body and author:

Image

All is working except this value nothing is being inserted in the DB coderequestData.data.toName = message_scope.toName;/code

I assume this value should have been set from codepromptName/code page, when I click on the list item. But it is not.

Thank you!

Hawk
Posts: 0
Joined: Mon Aug 04, 2014 11:23 am

AngularJS: How to get the value of selected list item

Hello,

Any update on this?

Regards,

Serhii Kulibaba
Posts: 150
Joined: Tue Aug 27, 2013 1:47 pm

AngularJS: How to get the value of selected list item

I don't see a variable "message" on that page. Pleas add a new variable message with type=message

Hawk
Posts: 0
Joined: Mon Aug 04, 2014 11:23 am

AngularJS: How to get the value of selected list item

Hi Sergiy

I added variable "message" of the type "message". I am still not getting anything inserted into toName in the following page.

Image

Please advise!

Hawk
Posts: 0
Joined: Mon Aug 04, 2014 11:23 am

AngularJS: How to get the value of selected list item

Hi Sergiy,

Appreciate it if you can advise me on this.
Let me know if you need more information

Thanks,

Serhii Kulibaba
Posts: 150
Joined: Tue Aug 27, 2013 1:47 pm

AngularJS: How to get the value of selected list item

Please share (http://devcenter.appery.io/documentat...) your app with a href="mailto:support@appery.io" rel="nofollow"support@appery.io/a and provide us with the following information:

1) App name
2) Test credentials if login functionality is implemented in your app
3) Detailed steps to reproduce the issue

Yurii Orishchuk
Posts: 0
Joined: Fri Feb 14, 2014 8:20 am

AngularJS: How to get the value of selected list item

Hi Hawk,

You did not pass "connection" (current item of array) to the function.

Thus you can not get current item values.

You need to:

1 pass "connection" to the function in "ng-click" attribute.

pre

consolelog(connection);

/pre

2 add "connection" parameter to your "consolelog" function.

3 in "consolelog" function you can use following code to access variable:

pre

console.log(connection.connection);

/pre

Regards.

Hawk
Posts: 0
Joined: Mon Aug 04, 2014 11:23 am

AngularJS: How to get the value of selected list item

Thank Yurii, Now I understand.

I have two other question, I hope you can help me with.

1) I need to add a condition to the list of messages displayed to display only the messages of the particular connection I selected in NamePrompt Page. I am not too familiar with Angular interface, and mapping is not clear here. Would you please advise?

2) I followed the tutorial, and the messages are being cleared every time I start new chat. (not from database, they are still stored. But they do not show in the frontend). How to display the history of the messages when I start new conversation? Is this something to change in the server script?

Deeply appreciated

Return to “Issues”