.all().one() does not work for numbers
See original GitHub issueThis works:
> Restangular.all("models").one("1").getRestangularUrl()
/api/models/1
This also works:
> Restangular.one("models", 1).getRestangularUrl()
/api/models/1
But this triggers an error:
> Restangular.all("models").one(1).getRestangularUrl()
Error: You're creating a Restangular entity with the number instead of the route or the parent. You can't call .one(12)
Shouldn’t this be allowed for consistency reasons?
Issue Analytics
- State:
- Created 9 years ago
- Comments:8 (4 by maintainers)
Top Results From Across the Web
Automatically number rows - Microsoft Support
Add sequential numbers to rows of data by dragging the fill handle to fill a column with a series of numbers or by...
Read more >SQL for ordering by number - 1,2,3,4 etc instead of 1,10,11,12
One way to order by positive integers, when they are stored as varchar , is to order by the length first and then...
Read more >Why the number input is the worst input - Stack Overflow Blog
The list isn't long, but the issues are rather jaw-dropping. So here's a short list of all the horrible things about the number...
Read more >Number - JavaScript - MDN Web Docs - Mozilla
Chrome Edge
Number Full support. Chrome1. Toggle history Full support. Edge12. Toggl...
EPSILON Full support. Chrome34. Toggle history Full support. Edge12. Toggl...
MAX_SAFE_INTEGER Full support. Chrome34....
Read more >How to use SUMIF function in Excel with formula examples
A good thing is that the function is available in all versions, from Excel ... When adding up numbers in one column based...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Sample 1 and 3 do not represent the same resource.
Restangular.all("models").one("1")
means the sub-resource named1
with currently no id inside the resourcemodels
(used to create an empty resource before doing a POST) whileRestangular.all("models").one(1)
would mean resource with id1
inside collectionmodels
but that’s whatRestangular.one("models", 1)
is for, and nobody really wants to have two ways to do the same thing.Same issue here, had to typecast to String in order to use it properly:
+1 to @ntrrgc way of using it, like
tasks.one(15).get()
, and if a String, parse internally to number.