【发布时间】:2015-05-31 17:58:47
【问题描述】:
我无法获得 select2 的值。 这是我的代码:
<select id="categoryId" class="category"
ng-model="selectedCategory"
ng-options="selectedCategories.name for selectedCategories in categories"
ng-change="selectedCategory()">
<option></option>
</select>
在我的控制器中我写了这个:
.....
function initializeSelect2 (){
$category.select2({
allowClear: true
});
}
$scope.selectedCategory = function (){
console.log('selectCategory: '+ $scope.selectedCategory);
}
【问题讨论】:
-
你需要使用
ui-select2github.com/angular-ui/ui-select2 这是select2的角度版本 -
请注意,ui-select2 已被弃用并为 select2@~3.4 编写,可能不适用于 select2@4.0
标签: angularjs jquery-select2 angularjs-select2