ng2-select Children version does not work

Created on 19 Jan 2017  路  5Comments  路  Source: valor-software/ng2-select

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.

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!

All 5 comments

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'}
]
}
]

Was this page helpful?
0 / 5 - 0 ratings

Related issues

jenb34 picture jenb34  路  5Comments

253936563 picture 253936563  路  5Comments

thanhngvpt picture thanhngvpt  路  5Comments

Garybhardwaj picture Garybhardwaj  路  3Comments

Kiwi15 picture Kiwi15  路  4Comments