angularUI select dropdown displays data only after entering a character

I am using AngularJS v1.2.15 and angular-ui / ui-select. My select HTML is:

<div class="form-group col-md-3">
    <div class="input-group select2-bootstrap-append">

      <ui-select ng-model="modelOwner.selected" theme="select2" class="form-control">
        <match placeholder="Select Owner">{{$select.selected.name}}</match>
        <choices repeat="item in owner | filter: $select.search">
          <span ng-bind-html="item.name | highlight: $select.search"></span>
        </choices>
      </ui-select>

      <span class="input-group-btn">
        <button ng-click="modelOwner.selected = undefined" class="btn btn-danger">
          <span class="glyphicon glyphicon-trash"></span>
        </button>
      </span>

    </div>    
  </div>

My call in controller is:

$scope.modelOwner = {};

OwnersFactory.query({}, function (data) {
  $scope.owner = data;
});

My service code:

bootstrapApp.factory('OwnersFactory', function ($http,$state,serviceUrl,$resource,$log) {

    return $resource(serviceUrl + 'owner/:id', {}, {
        show: { method: 'GET',  params: {}, isArray: false }
    })
});

Now, in my form i can view the values only after entering at least a single character. I want this select dropdown to display values just by clicking on the dropdown (not by entering any character.)

Possible Solution: if i could load my state only after all the AJAX calls have been made.

Please help me out here.

Answers


if you are using ui-router you can use resolve on each state, so that the call is resolved before initializing the controller

https://github.com/angular-ui/ui-router/wiki#resolve


Need Your Help

How do I read response headers + body from single POST using scala's dispatch lib

scala httpclient scala-dispatch

I have been trying to use the dispatch library to download a file via an http POST request. The server returns a "content-disposition" header suggesting a filename for the data file it returns.

Ruby on rails - need to send messages to emails at a particular time a week

ruby-on-rails ruby rubygems email-integration

I would like to know how i should go about with this project. I need to send emails to people once a week. However this has to be auto generated and sent at a certain time every week. How hard is t...