Skip to content
This repository has been archived by the owner on Oct 2, 2019. It is now read-only.

pre select input value #50

Closed
spyder86 opened this issue Apr 10, 2014 · 1 comment
Closed

pre select input value #50

spyder86 opened this issue Apr 10, 2014 · 1 comment
Labels

Comments

@spyder86
Copy link

How can i pre select value in the input field?

HTML code:

<ui-select name="source" ng-model="lead.modelSource.selected" theme="select2" class="form-control">
          <match placeholder="Select Source">{{$select.selected.name}}</match>
          <choices repeat="item in source | filter: $select.search">
            <span ng-bind-html="item.name | highlight: $select.search" ng-selected="selectSource(item.sourceId)"></span>
          </choices>
        </ui-select>

My JS code:

$scope.selectSource = function(sourceIdPassed)
    {
        if(sourceIdPassed == $scope.sourceId){
            return 'selected';
        }
    }

StackOverFlow Link:
http://stackoverflow.com/questions/22962755

@SimeonC
Copy link
Contributor

SimeonC commented May 26, 2014

You just set $scope.lead.modelSource.selected = $scope.source[indexOfSourceObjectSelected].
OR if you're dynamically loading then you could set it to a new object but you have to make sure that you reference the same object in the $scope.source array and the ...modelSource.seleced object.

@spyder86 spyder86 closed this as completed Oct 8, 2014
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

3 participants