petebacondarwin / angular-toarrayfilter Goto Github PK
View Code? Open in Web Editor NEWA filter to convert your objects to an array that can be filtered and sorted easily
A filter to convert your objects to an array that can be filtered and sorted easily
Hi,
The filter code checks whether the input provided is object or not and returns from there itself. Now for ng-repeat over an object like:
{"panel":"red","window":"blue","carpet":"green","doors":"white"} with the toArray Filter it doesn't work as the repeat returns the value and not the object itself and when it reaches the Filter, it checks for object in the first step itself and returns as the value provided is not object. Can you add support for such an object too?
It gives an error that $key cannot be reassigned when i try to udpate the object based on a button click.
Thanks in advance
Hello,
I guess there's a pretty simple reason to this filter not work with the ngRepeat below:
// Object
var collection = {
'AA': 'Value 2',
'BB': 'Value 1'
}
<!-- directive ngRepeat expression -->
<div ng-repeat="(key, value) in collection | toArray | orderBy:'value'">
{{ key }} - {{ value }}
</div>
But I cannot see what I'm doing wrong. Is this an expected problem with this type of ngRepeat with this object structure or there's something that I need to change?
Thanks!
It would be really cool, if you could provide a licence (preferably MIT) for your repo.
Should this filter work on nested properties as well? I'm trying to do the following:
<div ng-repeat="rest in menu | toArray | orderBy : 'rest.info.order' " ng-init="id = rest.$key">
which is not working. Any suggestions? I would not want to modify the structure either.
Hi,
I need same filter to convert this type of object as well:
var someObject = {
"id1" : "title1",
"id2" : "title2"
}
should return back as:
//converted to Array
[
{
$key: "id1",
value: "title1"
},
{
$key: "id2",
value: "title2"
},
]
Note: If any property gets a value type non-object (e.g String) , filter should only then add a new property as "value", this would contain that non-object or string value.
If you need me to work volunteer, would love to do :)
Cheers !
There are a few open issues, 1 PR, but I don't see any code-related activity. The bower package isn't up to date and no .min version of the file is provided. Do you need some help maintaining this repo? If so, I can help you @petebacondarwin
bower install --save angular-toArrayFilter
does not install the latest version (the line
if (!obj) return obj;
is missing).
Am I doing something wrong?
Thank you
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.