StackOverflow

http://stackoverflow.com/questions/11795010/accessing-external-values-from-within-knockout-js-observablearray-item-construct/11796407#11796407

by gurkavcu

HTML

<script src="https://cdnjs.cloudflare.com/ajax/libs/knockout/2.2.1/knockout-min.js"></script>
 <select  data-bind="value: selectedCountry , foreach : countryArray" >
        <!-- ko if: show -->        
       <option data-bind="value : name, text : name "></option>
       <!-- /ko -->
 </select>

JavaScript

function viewModel() {
    
    var self = this;
    this.countryArray = ko.observableArray([{"name" : "France" ,"show" : true},
                                            {"name" : "Italy" , "show" : true},
                                            {"name":"Germany" , "show" : false}]);
    
    this.selectedCountry = ko.observable("");
    
}

$(document).ready(function() {

    var vm = new viewModel();
    ko.applyBindings(vm);

})