Page 1 of 2

AngularJS: How to get the value of selected list item

Posted: Wed Apr 27, 2016 4:30 am
by Hawk

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


AngularJS: How to get the value of selected list item

Posted: Wed Apr 27, 2016 9:16 am
by Serhii Kulibaba

Hello,

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


AngularJS: How to get the value of selected list item

Posted: Wed Apr 27, 2016 10:38 am
by Hawk

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!


AngularJS: How to get the value of selected list item

Posted: Fri Apr 29, 2016 7:19 am
by Hawk

Hello,

Any update on this?

Regards,


AngularJS: How to get the value of selected list item

Posted: Fri Apr 29, 2016 11:41 am
by Serhii Kulibaba

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


AngularJS: How to get the value of selected list item

Posted: Sun May 01, 2016 5:55 am
by Hawk

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!


AngularJS: How to get the value of selected list item

Posted: Wed May 04, 2016 2:32 am
by Hawk

Hi Sergiy,

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

Thanks,


AngularJS: How to get the value of selected list item

Posted: Wed May 04, 2016 10:59 am
by Serhii Kulibaba

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


AngularJS: How to get the value of selected list item

Posted: Fri May 06, 2016 4:59 am
by Yurii Orishchuk

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.


AngularJS: How to get the value of selected list item

Posted: Sat May 07, 2016 11:11 am
by Hawk

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