The Children version does not work. Not even on the Demo page:
http://valor-software.com/ng2-select/
(Neither in my development. It did work, but recently I updated my package.json along with the downloaded node_modules. First I experienced this error on my page, but the official demo does not work either.)
Checked in the latest Firefox and Chrome.
Currently the latest is v1.2.0
I have downgraded ng2-select in my development to v1.1.2 and with this version Children works again.
I had the same problem. The problem is that the children version expects an id. You can just set a dummy id for your parents and it's working again!
public items:Array<any> = [
{
id: 1,
text: 'Austria',
children: [
{id: 54, text: 'Vienna'}
]
},
{
id: 2,
text: 'Belgium',
children: [
{id: 2, text: 'Antwerp'},
{id: 9, text: 'Brussels'}
]
}
]
but item set is
public items:Array
{
id: 1,
text: 'Austria',
},
{
id: 2,
text: 'Belgium',
children: [
{id: 2, text: 'Antwerp'},
{id: 9, text: 'Brussels'}
]
}
]
not work
Hi,
Is there any way to style the parent item?
From the template, it seems that if the list contains childrens the 'text' of the parent is rendered as it is.
However for the child items, it is sanitized and injected inside the Div.
From the below example, i want to add my custom style to the parent item(different style to different parent, hence can't use the existing class "dropdown-header" for styling), it works for childrens but doesn't work for parent.
public items:Array
{
id: 1,
text: <div class='level-indent-1'>Austria</div>,
children: [
{id: 54, text: <div class='level-indent'>Vienna</div>}
]
},
{
id: 2,
text: <div class='level-indent-2'>Belgium</div>,
children: [
{id: 2, text: 'Antwerp'},
{id: 9, text: 'Brussels'}
]
}
]
Most helpful comment
I had the same problem. The problem is that the children version expects an id. You can just set a dummy id for your parents and it's working again!