Skip to content
This repository was archived by the owner on Apr 12, 2024. It is now read-only.
This repository was archived by the owner on Apr 12, 2024. It is now read-only.

When initializing ngModel to the last item of a select control inside of a $timeout, UI is not updating #10718

@pixelbits-mk

Description

@pixelbits-mk

When defining a select control as follows:

 <select data-ng-model="selected" data-ng-options="n for n in [0,1,2,3]"></select>

And initializing the 'selected' variable to the last item inside of a $timeout handler in an ngController:

function ctrl($scope, $timeout) {
  $timeout(function() {
      $scope.selected = 3;
  },50);
}

The drop down list remains blank (it should be initialized to 3).

Here is a plunker demonstrating the issue: http://plnkr.co/edit/AGlwxCoe1vlvzXyvvk2b?p=preview
Here is the original stack overflow post where the issue was found: http://stackoverflow.com/questions/27892564/angular-strange-behavior-with-ng-options

This issue exists for version 1.2.26, and 1.2.28, but is working in version 1.3.*

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions