Skip to content
This repository was archived by the owner on Feb 19, 2025. It is now read-only.
This repository was archived by the owner on Feb 19, 2025. It is now read-only.

ui-select2 with no initial options #228

@daryllstrauss

Description

@daryllstrauss

I had a controller that needed to initialize a ui-select2 from data that would be fetched from a service. The controller basically did this:

`$scope.allprojects=Project.query({'scope':'all'});`

The partial was written like this:

<select ui-select2 ng-model='project'>
<option ng-repeat='proj in allprojects' value="{{proj._id}}">{{proj.name}}</option>
</select>

It had strange inconsistent results. Sometimes it worked fine.

  1. The menu would be empty to start and would be wide enough to hold my widest project string.
  2. The menu would default to the first item in the project list.
  3. The model would track changes in the ui-sliders.

Most of the time it would fail:

  1. The menu would be very narrow, just showing me the triangle.
  2. There was no item selected at startup.
  3. If I opened the ui-select2 I would see the list of projects, and I was able to select them, but my model wouldn't update.

I worked around the problem by adding a:

Project choice before the repeating clause. That would initialize to the word "Project", but I noticed the menu was only as wide as the word "Project" not the widest choice. If I selected a wider choice the menu would resize. The model would update correctly as the menu changed.

I hope that's enough information for you to diagnose with.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions