Search code examples
javascriptangularjsjsonionic-frameworkhybrid-mobile-app

Ionic search popup with JSON value


Working on Ionic Search with Popup. It is working on

 $scope.selectables = [
    1, 2, 3 ];

But I want it to work on json

 $scope.countries = [
    {id: 1, text: 'USA', checked: false, icon: null}, 
    {id: 2, text: 'France', checked: false, icon: null}, 
    {id : 3, text: 'Japan', checked: true, icon: null}];

When I click on Select it button then Bind value USA, France, Japan. I don't want to push value in Array.

The code I'm using can be found on codepen.io on the next link:

http://codepen.io/anujsphinx/pen/Lbryzz


Solution

  • change your options options="selectables" to options="countries" and print it as option.text to display country name and here is the working plunker check it

    <div class="item item-body">
              <button class="button button-positive" modal-select="" ng-model="someModel" options="countries" modal-title="Select " has-search="true">
                {{someModel.text}} 
                <div class="option">
                  {{option.text}}
                </div>
              </button>
                   <div class="item">
              someModel: {{someModel.text}} 
            </div>
            </div>