suppose there are so many fields in js object and i want to load only few not all. i was searching on this for getting answer. i got one but i am not sure this is right one.
see the fiddle http://jsfiddle.net/vojtajina/js64b/14/
see this code ng:repeat="(i,th) in head" this is the way where we need to specify something in bracket. i have confusion here. so anyone can help me to understand how to load few selected data with ng-repeat. thanks
If i understand correct you want to know what the (i,th) values print:
First i suggest that you read on the ng-repeat documentation
i is the key of your object and th is the value:
scope.head = {
a: "Name",
b: "Surname",
c: "City"
};
So for this object example that your provided i equals to a,b,c and th equals to "Name", "Surname","City"
Related
For each item in array1, I want to filter array2 by the array1 item the bot is currently in.
Within an Edit an array property, if I filter array2 hard-coded like so it creates a nice array:
"changeType": "push",
"itemsProperty": "user.array2",
"value": "=where(json(user.apiResponse.content).value,x,x.myKey=='magazine')"
However if I use a dynamic key based on the current item in array1, this doesn't work:
"changeType": "push",
"itemsProperty": "user.array2",
"value":"=where(json(user.apiResponse.content).value,x,x.myKey==concat('\'',json(dialog.forEachThing.value).name,'\''))
I've tried setting a property, user.myFilter and passing that, as below.
"property": "user.myFilter",
"value": "=concat('\\'',json(dialog.forEachThing.value).name,'\\'')"
And while this user.myFilter evaluates correctly to 'magazine', the Edit an array property/push doesn't get any values.
I'd really welcome any thoughts on where I'm going wrong. I've tried a few things like '''' in user.myFilter but these evaluate as null.
Ok, updated answer here for those who follow.
Turns out I was wrong. In .Net anyway, the solution is to simply not wrap the variable in single quotes. Thanks to Dana V in github for the heads up.
It seems that may not work in Javascript however.
Here's a simple example of what I'm after:
/* source array in clues collection: */
clues = [
{ title: "Islero", answer: 5 },
{ title: "Miura", answer: 17 },
];
/* user collection: */
{
name: "Bob",
userClues: [
{/ref to clues[0]/, solved: true},
{/ref to clues[1]/, solved: false}
]}
{
name: "Wallace",
userClues: [
{/ref to clues[0]/, solved: true},
{/ref to clues[2]/, solved: true}
]}
The primary "clues" array is to be updated and modified as needed, adding or removing clues and changing their values. The "userClues" array in each user's document is to exactly mirror the source clues array by reference, but I'd like to add an additional "solved" field to each element that is unique to each element in each "userClues" array. The "solved" field isn't linked or referenced to anything, each one stands alone. In this example, adding a third element to the "clues" array would add a third element to each "userClues" array along with it's own solved field for each user. Removing this third clue would also remove the entire third element from each "userClues" array.
I'm thinking a schema could be used to append the "solved" field automatically to each "userClues" element, but I'm not sure how you could spread the primary "clues" array into the "userClues" array by way of reference. Every example of referencing I've seen uses the '_id' to link the elements, so I don't see how a schema could apply to a pointer. Any advice or alternative solutions to this problem are greatly appreciated.
I'm trying to convert an Object array into an array without use "let item of array" on html, I already google a lot but nothing that I find works.
Why I don't use loops? because I pretend to display data inside a page that comes from a liteSQL database, so all the data that I extract from that it's an Object and sure I can display the data without issues if I use a loop like "let item of array" but in this case I just want to show information on the HTML like item.name or item.avatar
Thanks in advance for any help, If you guys need more information please let me know.
The database have students so every array have: name, age, avatar, etc, so I try to show some like a profile after they tap the name on the list
EDIT:
What you are receiving from your server is an array of objects.
array of objects ->
[{
key1:vlaue1,
key2:value2
},
{
key1:vlaue1,
key2:value2
}]
You refer the values here by using array[0]['key1'] array[0]['key2'] and so on
In your case, you are receiving only one object in the array, so simply use array[0].name array[0].age and so on
Thanks for the help, I actually found the solution by my self, I just need to use:
item: array = <array>{};
in order to use my object array as a simple array items without any loop on html
How do you get the id for the underlying record in a combobox with dojo? I've tried altering the following sample but all I can get is the text shown to the user (the "name" property of each array element), and NOT the state's two-letter abbreviation ("id" property).
http://dojotoolkit.org/reference-guide/1.10/dijit/form/ComboBox.html#id3
thanks. PS, I'm a total noob with dojo. This is my first experiment with it.
It's like #CodeCrisis said, you can get the item by using dijit.byId('stateSelect').item. Though I'm not really pleased with how outdated the docs are (the dijit.byId()command is deprecated), this is a proper 1.10 solution:
query("button").on('click', function() {
console.log(comboBox.get('item'));
});
This will return the selected record in the store (containing both the id and name properties in this case).
A full, working example can be found here: http://jsfiddle.net/zt6xggL8/
How about this...
base on the link given
http://dojotoolkit.org/reference-guide/1.10/dijit/form/ComboBox.html#id3
change this onclick function
onClick="alert(dijit.byId('stateSelect').get('value'))"
into
onClick="alert(dijit.byId('stateSelect').item.id)"
i know this is not the best answer but i hope this will help you..
check out the answer of Philippe
Dojo : ComboBox selected and show data id
hehehe... :)
just passing by...
Not the prettiest but this works. Basically need to query the 'store' variable for the name that is being displayed when you just use 'value'. [0] denotes the first object in the store list, so if you have multiples with the same name, you'll need to use the foreach() function.
<button onClick="var namevar=dijit.byId('stateSelect').get('value');
alert(dijit.byId('stateSelect').get('store').query({name:namevar})[0].id);">
Get value
</button>
i am facing some weird issue in ordeBy, i know this should be very simple but couldn't make out
Please look at a below plunker, where the orderBy by value not showing correct output, i don't no why :(
DEMO PLUNKER
If you want to keep doing that, you'll have to create a filter for inverted indexes based on the property you want (here the whole object) so that you can retrieve the key and hence the value
You will have to convert the numbers to strings and make sure the strings are the same length
var temp = {"054": "A",
"244": "B",
"344": "C"};
this works.