Angularjs 如何使用“角度”自动选择下拉选项

Angularjs 如何使用“角度”自动选择下拉选项,angularjs,Angularjs,使用angular自动选择下拉选项的最佳方法是什么?例如 //controller $scope.data = [{id: 1, status: "sent"}, {id: 2, status : "Not Sent"}] //view.. How do i set it here to always have the status on "Not sent" to be already selected when the page is loaded? <div>

使用angular自动选择下拉选项的最佳方法是什么?例如

//controller
$scope.data = [{id: 1, status: "sent"}, {id: 2, status : "Not Sent"}]

//view.. How do i set it here to always have the status on "Not sent" to be already selected when the page is loaded? 
 <div> 

     <select> 
               ng-options="status.status as status.status for status in data">

   </select>

</div>
//控制器
$scope.data=[{id:1,状态:“已发送”},{id:2,状态:“未发送”}]
//视图。。我如何在这里设置它,使其在加载页面时始终处于“未发送”的状态?
ng options=“status.status as status.status for status in data”>
谢谢你抽出时间!AL

//控制器
// controller
$scope.data = [{id: 1, status: "sent"}, {id: 2, status : "Not Sent"}];
$scope.selectedOption = $scope.data[0];

// view
<select ng-model='selectedOption' ng-options='d as d.status for d in data'>
$scope.data=[{id:1,状态:“已发送”},{id:2,状态:“未发送”}]; $scope.selectedOption=$scope.data[0]; //看法
//控制器
$scope.data=[{id:1,状态:“已发送”},{id:2,状态:“未发送”}];
$scope.selectedOption=$scope.data[0];
//看法

您应该为select标记定义模型。 试试这个

angular.module('myApp',[]).controller('myTest',function($scope){
$scope.data=[{id:1,状态:“已发送”},{id:2,状态:“未发送”}];
$scope.select=$scope.data[0]。状态;
});

您应该为select标记定义模型。 试试这个

angular.module('myApp',[]).controller('myTest',function($scope){
$scope.data=[{id:1,状态:“已发送”},{id:2,状态:“未发送”}];
$scope.select=$scope.data[0]。状态;
});

您刚刚设置了
model=“string”

var myApp=angular.module('myApp',[]);
myApp.controller('MyCtrl',函数($scope){
$scope.data=[{id:1,状态:“已发送”},{id:2,状态:“未发送”}]
$scope.selectedData=$scope.data[1];
});

您刚刚设置了
model=“string”

var myApp=angular.module('myApp',[]);
myApp.controller('MyCtrl',函数($scope){
$scope.data=[{id:1,状态:“已发送”},{id:2,状态:“未发送”}]
$scope.selectedData=$scope.data[1];
});