title: AngularJs: How make ui-select working properly?
body: <p><strong>THE SITUATION:</strong></p>
  
  <p>I am making an angular app where I have to use ui-select: in the user info page, in the select have to be possible to choose one or many tag.
  It is almost working, except from the fact that i have problems to get and display the pre-existent tags.</p>
  
  <p><strong>THE CODE:</strong></p>
  
  <p><strong>View:</strong> </p>
  
  <pre><code>&lt;ui-select multiple ng-model="info_data.tags" theme="bootstrap" ng-disabled="disabled"&gt;
  
    &lt;ui-select-match placeholder="Select tag..."&gt;{{$item.name}} &lt;/ui-select-match&gt;
  
    &lt;ui-select-choices repeat="tag in all_tags | propsFilter: {name: $select.search}"&gt;
  
      {{tag.name}}
  
    &lt;/ui-select-choices&gt;
  
  &lt;/ui-select&gt;
  
  &lt;p&gt;Selected: {{info_data.tags}}&lt;/p&gt;
  </code></pre>
  
  <p><strong>Controller:</strong></p>
  
  <pre><code>$http({
  
      url: base_url + 'main/db_get_all_tags',
      method: "POST",
  
   }).success(function (data) {
  
      $scope.all_tags = data;
  
  });
  
  $scope.show_info = function() {
  
      var result_info = DbService.get_info( $stateParams.db_data_id );
  
      result_info.then( function( data )
      {
          $scope.info_data = data;
  
      });
  
  };
  </code></pre>
  
  <p><strong>ATTEMPT 1:</strong> </p>
  
  <p>It happens a very strange behavior. 
  I don't see the tags in the info page of the user, and not even in the ui-select.
  Except if refresh 5/6 times, then suddenly it will magically work, displaying the tags in the user info page and in the ui-select.
  In both cases, working and not, i get several error message of the same kind:</p>
  
  <blockquote>
    <p>Cannot read property 'length' of undefined.</p>
  </blockquote>
  
  <p><strong>ATTEMPT 2:</strong> </p>
  
  <p>In order to resolve this problem, I have added this code in the controller:</p>
  
  <pre><code>$scope.info_data = { tags: [] };
  $scope. all_tags = [];
  </code></pre>
  
  <p>And i don't get anymore any error message. The app is stable and i can see the proper tags in the user info page.
  The only problem is that the tags are not loaded anymore in the ui-select.</p>
  
  <p>If i select a new tag then it works fine, but i loose the pre-existing tags.</p>
  
  <p><strong>QUESTION(s):</strong> </p>
  
  <p>How can i make ui-select properly working? (currently v0.8.3)
  There is a problem of conflict?</p>
  
  <p>How can i properly call pre-existent data from the server?</p>
  
  <p>Thank you very much!</p>