Take the 2-minute tour ×
Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.

I have an array:

$scope.default = [
    {name:'bigid',desc:'Incrementing ID using <code>BIGINT</code>'},
    {name:'timestamps',desc:'Add <code>TIMESTAMP</code> columns'},
    {name:'ntimestamps',desc:'Allow <code>TIMESTAMP</code> null'},
    {name:'softdelete',desc:'Support <code>SOFTDELETE<code>'},
    {name:'rem_token',desc:'Adds <code>remember_token</code>'}
];  

But, I wanna filter that I have result:

[
    {name:'bigid'},
    {name:'timestamps'},
    {name:'ntimestamps'},
    {name:'softdelete'},
    {name:'rem_token'}
];  

Help me, please. Should I can do this only with AngularJS Filter?

share|improve this question

1 Answer 1

up vote 1 down vote accepted

You can use .map

$scope.default = [
    {name:'bigid',desc:'Incrementing ID using <code>BIGINT</code>'},
    {name:'timestamps',desc:'Add <code>TIMESTAMP</code> columns'},
    {name:'ntimestamps',desc:'Allow <code>TIMESTAMP</code> null'},
    {name:'softdelete',desc:'Support <code>SOFTDELETE<code>'},
    {name:'rem_token',desc:'Adds <code>remember_token</code>'}
];

$scope.default = $scope.default.map(function (el) {
    return {name: el.name};
});
share|improve this answer
1  
Thanks you. It is exactly what i need :) –  user3584125 17 hours ago

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.