2016-08-04 1 views
0

나는 선택 상자를 만들어 다음 줄을이 :Angular가 null 옵션을 표시하지 않도록 알려주는 방법은 무엇입니까?

<select class="form-control" ng-model="selectedConfig" ng-options="config as config.name for config in configs"></select> 

문제는이 상자를 하나 널 (null) 옵션을 제공한다는 것입니다. enter image description here

제 질문은 ng-options을 null이 아닌 옵션 만 만드는 방법입니까?

+1

가 자동으로 추가하는'NG-model'은 옵션 중 하나를 일치하지 않을 때. 옵션을 선택하자마자 제거됩니다. 그것이 나타나지 않게하려면,'selectedConfig'의 기본값을'config' 아이템 중 하나에 설정해야합니다. – Lex

답변

0

편집 답 : 이 selectedConfig에 대한 값을 정의합니다

$scope.selectedConfig = $scope.configs[0] ; 

올드 답 : 필터를 추가 할 수 있습니다!

<select class="form-control" ng-model="selectedConfig" ng-options="config as config.name for config in configs | filter:{name: ''}"></select> 

참조 : 각도 Angularjs filter not null

+0

'ng-model '값이 옵션과 일치하지 않을 때 자동으로'