嵌套对象上的角度过滤器,用于显示找到的对象的父级和子级 [英] angular filter on nested object, to show both parent and children of object found

查看:63
本文介绍了嵌套对象上的角度过滤器,用于显示找到的对象的父级和子级的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在嵌套列表上实现搜索。这个想法是,当在列表上执行搜索时,找到的元素的父母和孩子都可见。



现在我有一个列表,我是能够搜索一个元素并返回该元素的所有父元素。



但是我无法向孩子展示所有可见的元素。



这里有一个小提琴,可以过滤并显示找到的所有元素的父母。清单和搜索 - Plunker [ ^ ]



我添加了一段添加节目的代码对于一个可见父母的每个孩子的财产,但仅限于孩子有更多的孩子。



  function  setChildren(child){
var i;
if (child){
for (i = 0 ; i< child.length; i ++){
child [i] .show = true ;
setChildren(child [i] .children);
}
}
}



试图向孩子们展示 - Plunker [ ^ ]



有关如何实现这一点的任何想法?

解决方案

< a href =http://stackoverflow.com/questions/21453697/angularjs-access-parent-scope-from-child-controller> angularjs从子控制器访问父作用域 - Stack Overflow [ ^ ]





孩子越多


父母添加



I'm trying to implement a search on a nested list. The idea is that when a search is performed on the list both the parents and children of the found element are visible.

Right now I have a list and I'm able to search for a element and return the all the parents for the element.

But I'm not able to show the children of all the elements that are visible.

Here is fiddle that filters and shows the parents of all elements that are found. plunker with the list and search--Plunker[^]

I added a piece of code that adds show property to every child of a visible parent but only if the children has few more children.

function setChildren(child) {
    var i;
    if (child) {
        for (i=0;i< child.length;i++){
            child[i].show = true;
            setChildren(child[i].children);
        }
    }
}


attempt to show children--Plunker[^]

Any thoughts on how this can be achieved?

解决方案

angularjs Access parent scope from child controller - Stack Overflow[^]


the more the in child the more


parent is add


parent.


这篇关于嵌套对象上的角度过滤器,用于显示找到的对象的父级和子级的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆