Reputation: 9733
I'm doing a select with this code:
Why this option tag is being generated ?
<option value="? string:feminino ?"></option>
it only happens when:
html before :
<select id="gender" ng-model="genderMarked" ng-change="updateGender(genderMarked)" >
<option value="">Select a gender</option>
<option ng-value="collection.slug" ng-repeat="collection in collectionsGender">{{collection.title}}</option>
</select>
Html after:
<select id="gender" ng-model="genderMarked" ng-change="updateGender(genderMarked)" class="ng-pristine ng-valid ng-touched"><option value="? string:feminino ?"></option>
<option value="? string:feminino ?"></option>
<option value="">Select a gender</option>
<option ng-value="collection.slug" ng-repeat="collection in collectionsGender" class="ng-binding ng-scope" value="masculino">Masculino</option>
<option ng-value="collection.slug" ng-repeat="collection in collectionsGender" class="ng-binding ng-scope" value="feminino">Feminino</option>
<option ng-value="collection.slug" ng-repeat="collection in collectionsGender" class="ng-binding ng-scope" value="infantil">Infantil</option>
</select>
And I'm getting the gender already marked from the url (if user refresh the page) with this code:
if($stateParams.genderSlug){
$scope.genderMarked = $stateParams.genderSlug;
}else{
$scope.genderMarked = '';
}
Upvotes: 0
Views: 32
Reputation: 164733
I find ng-options
to be much easier to use than repeated <option>
tags.
Try this
<select id="gender" ng-model="genderMarked" ng-change="updateGender(genderMarked)"
ng-options="collection.slug as collection.title for collection in collectionsGender">
<option value="">Select a gender</option>
</select>
Upvotes: 1