<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>select第一行留白</title>
<script src="http://cdn.static.runoob.com/libs/angular.js/1.4.6/angular.min.js"></script>
</head>
<body>
<div ng-app="myApp" ng-controller="myCtrl">
<p>選擇網站:</p>
<select ng-model="selectedSite">
<option ng-repeat="x in sites" value="{{x.site}}">{{x.site}}</option>
</select>
<h1>你選擇的是: {{selectedSite}}</h1>
</div>
<script>
var app = angular.module('myApp', []);
app.controller('myCtrl', function($scope) {
$scope.sites = [
{site : "Google", url : "http://www.google.com"},
{site : "Runoob", url : "http://www.runoob.com"},
{site : "Taobao", url : "http://www.taobao.com"}
];
$scope.selectedSite=$scope.sites[0].site;// 這裏只要把想要第一次出來的url放在這裏就可以實現option默認出現的效果了
});
</script>
<p>該實例演示了使用 ng-repeat 指令來創建下拉列表,選中的值是一個字符串。</p>
</body>
</html>
解釋:只要添加上 $scope.selectedSite=$scope.sites[0].site;
這行,select就會有默認效果
效果如下: