0

So, I've been trying to filter an select with another based on this informations came from a web service:

{
    sections: [
        {
            st_id: '1',
            st_nm: 'name1',
            blocks: [
                {
                    bl_id: '1',
                    bl_nm: 'block1'
                }
            ]
        },
        {
            st_id: '2',
            st_nm: 'name2',
            blocks: [
                {
                    bl_id: '2',
                    bl_nm: 'block2'
                },
                {
                    bl_id: '2-1',
                    bl_nm: 'block2-1'
                }
                // ... and so on
            ]
        }
        // ... and so on
    ]
}

I tried a lot of things and combinations, but I'm really new in Angular and nothing works. I need filter the second select, and fill with the "blocks" information, with the "st_nm" field selected in the first select element.

I'm grateful for your answers!

1 Answer 1

2

I think I know what you're trying to do here and here's my suggestion:

<select id="st_select" ng-model="st_selected" ng-options="sect.st_nm for sect in sections">

<select id="blocks_select" ng-model="block_selected" ng-options="block.b1_nm for block in st_selected.blocks">
Sign up to request clarification or add additional context in comments.

1 Comment

Thank you! Now, did you know how can I make the option output be customized? I'd like to put more information than "bl_nm", I want something like this: <select><option>Block 2-1 ; Name block2-1</option></select>

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.