在我的玉器中
select.thumbnail.form-control(ng-
model="txtPaymentStatus",id="txtPaymentStatus",
ng-options="type.type for type in PaymentStatus")
在我的角度js文件中
$scope.PaymentStatus = [{ type : "Pending" }, { type : "Done" }];
console.log($scope.txtPaymentStatus);
此处输出未定义。为什么?请帮忙
答案 0 :(得分:1)
你看到那里未定义,因为当控制器被创建并且没有选择任何内容并且你没有将值设置为$ scope.txtPaymentStatus时运行console.log。
var app = angular.module('app', ['ui.select']);
app.controller('myController', function($scope) {
$scope.PaymentStatus = [{ type : "Pending" }, { type : "Done" }];
console.log($scope.txtPaymentStatus);
});
<script src="https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.4.3/angular.min.js"></script>
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/angular-ui-select/0.12.1/select.min.js"></script>
<div ng-app='app' ng-controller='myController'>
<select class="thumbnail form-control" ng-model="txtPaymentStatus" id="txtPaymentStatus" ng-options="type.type for type in PaymentStatus"></select>
{{ txtPaymentStatus }}
</div>