1

I'm getting blank data while loading JSON data into Dropdown using Angular ng-options.

My JSON Values

"tagFormat": {
        "displayText": "Tag Format",
        "options": [{
            "value": "js",
            "name": "JS"
        }, {
            "value": "vast",
            "name": "VAST"
        }]
    },

HTML View

<div class="select_padding">
    <select class="form-control" ng-options="otf.value as otf.name for otf in details.tagFormat.options">
         <option>Select Tag Format</option>
    </select>
</div>

here details is my scope variable.

how to get these data and also next time I need to use selected value. so Do I need to bind with ng-model ?

Thanks

1 Answer 1

2

Here is the working code:

    <select class="form-control" ng-options="item as item.name for item in details.tagFormat.options track by item.value" ng-model="selected">
         <option value="">Select Tag Format</option>
    </select>

In $scope.selected you read the selected item.

Check this example on Codepen: http://codepen.io/beaver71/pen/Vexwmr

Sign up to request clarification or add additional context in comments.

Comments

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.