Is there a limitation with the number of values within an angular orderby predicate? I can't get anything with more than 2 fields to work. Meaning anything past the 2nd index doesn't work. If I shift the fields around and put the one that is 3rd to first it works.
Example:
['VendorName','ProductName','-ProductCost']
The value in the 3rd position or index 2 appears to be ignored unless i move it within the 1st or 2nd positions of the array. I could be completely overlooking something, but I can't get it to work. The first two fields work fine.
Any info would be greatly appreciated.
Seems to work correctly in this Plunker:
http://plnkr.co/edit/nHBQrJKXuGNkZ55VNPl8?p=preview
Click the Sort Name, Phone, Age button.
Related
I'm trying to write a cell formula which can essentially create a single playlist of songs.
Currently the songs are grouped by decade, but I'd like to be able to see a single list of everything that has been ticked.
I tried an array formula, but it only returned the first ticked song. Plus not sure how to make the array formula include the adjacent lists.
I tried a FILTER function, it works for one list of songs, but I don't know how to get it to append the other lists on the end.
Could I use a QUERY function? Not sure how though.
Many thanks!
try:
={"LIST"; FILTER({C:C; F:F}; {B:B; E:E}=TRUE)}
awesome question! You were super close in your filter example, one more filter in your array would've done it :)
Example Image:
Example Formula:
={"LIST"; FILTER(C:C, B:B=TRUE); FILTER(F:F, E:E=TRUE)}
Sometimes you need to ng-if or ng-show an item in html based on some choices made earlier. One of these for me is "Additional Item". You can enter one set of information, and also if you want, an additional set. This creates an array of 2 similar objects. With this setup, you can only have 1 or 2 objects in this array. (important, since the scope of this question needs to be limited this way)
I want to ng-show an html directive based on "myItemsArray.length > 1". Since the array can (read should) only be 1 or 2 in length (not 0), this should work. However, it does not, because AngularJS seems to be adding an item "proto" to the array which adds to the count. See the image.
The problem is, proto makes the array length equal 2. I am not going to just look for length > 2 because i really don't know if i can count on proto always being there, and i just think thats bad practice anyway.
Also, i know there are MANY other ways of doing this (setting a boolean, or using another var to indicate etc, but i really just want to work with count of items in the array because "business logic"..
EDIT:
After doing a little debugging, i'm seeing that i have an array of "Object, undefined". How is this even possible :)
Some search lead me to this. Why are some values in my array undefined
EDIT:
Seems that using a delete may cause this problem
So the other day I had my colleague review my code and he saw that I was using array[0], in Java terms this is basically getting the first element of the array. I did this several times for different purposes, all of which is to get the first element in an array/collection, for example list.get(0), to which he strongly disagreed with.
His argument was that somebody from non-programming background would have problem understanding it and using 0 in such cases is basically hard-coding, which is bad practice. I google-ed several times and all suggestions to getting the first element in an array or any collection is providing them the index, which is 0 in this case.
Could anyone provide me with a suggestion on getting the first element in a meaningful way?
Try using linkedlist's getfirst method to get the first element of the list.
If you were to use an ArrayList is backed by an array and hence its perfectly valid to use index as 0 to get first element.
How can I search names starting from first letter that user types, I want to know if user types B then names starting from B must be displayed rather than "SBI" word where B comes in second position. I want to search specific words which has first word match.
for example: if
list ={SBI,
BSI,
isb,
bsisib,
be happy,
dont worry,
hello}
Then If i type h character then I want all the words starting from 'h'. but when i tried it shows 'be happy' 'hello' result for h. I want hello only. Thank you
If you're list isn't extremely long try applying a regular expression on each item in ng-repeat filter.
Not sure if you want first word or first character in each word.
Try the following plunker.
If you are using this on input field, then
I suggest you to use an existing autocomplete solution for angularjs. There are many of them out there and are quite easy to use.
http://ngmodules.org/modules/ngAutocomplete
Plunkr:http://plnkr.co/edit/il2J8qOI2Dr7Ik1KHRm8?p=preview
http://angular-ui.github.io/bootstrap/
Check the typeahead from angular ui bootstrap.
Or just google angularjs autocomplete, you will find tons of results.
I am using
dojo.query('input,select',myDiv)[0].focus();
to focus the first input element found in a div container.
This will work in Firefox, but not in IE 7.
IE 7 only takes the first query into consideration:
dojo.query('input,select')[0] will select the first input element,
even if a select element is first.
dojo.query('select,input')[0] will select the first select element,
even if an input element is first.
Does anybody know a workaround for this?
If I recall correctly, dojo.query does not necessarily guarantee "chronological" order within the NodeList it returns, especially for complex queries. This is generally due to the fact that for some browsers / in some scenarios, it does have to cobble multiple disparate result sets together, and trying to reorder this based on where each element is in the document would probably be far more of a performance hit than it's worth.
That said, off the cuff I'm not sure what to suggest as an alternative. It'd be easy enough to find the first of one OR the other separately, just not while looking for both within the same query.
If your form has some kind of consistent markup around your inputs (e.g. each field is inside let's say, a div with class="field"), I suppose you could do something like this:
dojo.query('.field:first-child select, .field:first-child input')