我在HTML頁面中創建列表:如何獲得所選項目的值
<label class="item item-input">
<span class="input-label">Select date</span>
<select ng-model="search.dateOption" ng-options="opt as opt.label for opt in options">
</select>
</label>
在我的控制器中我定義的選項:
$scope.options = [
{ label: 'Today'},
{ label: 'This week'},
{ label: 'This month'},
{ label:'Other'}
]
我用下面的函數來獲得所選擇的項目:
$scope.selectedDate = function(){
$scope.search={}
console.log($scope.search)
}
我在我的控制檯中得到undefined
。
謝謝您的答覆。它在這裏工作,但在我的項目並沒有工作。可能是我的angularjs版本的利益。我正在使用1.5.5 –
編號在控制檯顯示什麼? –
沒有任何東西顯示在控制檯只是'undefined'。'
' –