2016-04-07 6 views
0

Ich versuche, Daten in Combobox zu initialisieren, und ich habe alle Möglichkeiten ausprobiert, aber nichts:ng-init funktioniert nicht Daten in Combobox inizialize (eckig)

<select ng-init= "account.username = githubaccounts[0].username" data-ng-model="account" data-ng-options="account.username for account in githubaccounts" 
        class="btn btn-default" data-container="body"> 

      </select> 

<div class="form-group" ng-show="account.username == 'Other'"> 
      <label for="groupNameTxt">Group Name:</label> 
      <input type="text" class="form-control" name="groupNameTxt" id="groupNameTxt" placeholder="Enter Group Name..." ng-model="group.groupName"> 
      </div> 

Andere Art und Weise, dass es funktioniert, ist dies:

<select class="btn btn-default" data-container="body" 
      ng-init="githubaccounts[0].username" ng-model="account"> 
     <option ng-repeat="account in githubaccounts" value=""> 
        {{account.username}} 
     </option> 
</select> 

Aber dann ng-Show nicht funktioniert:

Irgendwelche Ideen? Vielen Dank.

Antwort

0

Fabrikat folgende Änderungen im Code

<select ng-init= "anyModelVariable.username = githubaccounts[0].username" data-ng-model="anyModelVariable.username " data-ng-options="account.username for account in githubaccounts" 
class="btn btn-default" data-container="body"> 
</select> 

Änderungen: 1. Verwendung verschiedener Variablen in ng-Modell anderen Konto dann.

  1. initialisiere die gleiche Variable ng-model mit githubaccounts [0] .username.
+0

nein, es funktioniert nicht wieder :(Danke trotzdem –