Angularjs 在 bootstrap 选择器中不工作
Angularjs not working in bootstrap selectpicker
我正在创建一个 Web 应用程序,我在其中使用 bootstrap select 选择器 select.. 但我正在使用 angularjs 来填充 select 选择器.. 我有 2 select 其中一个的内容是根据第一个 select 值填充的,无需重新加载.. 我可以在没有 selectpicker 的情况下完美地工作,而它不会'使用 select 选择器时无法正常工作。我的代码是
<div class="form-group" data-ng-controller="MARK_ENTRY_CONTROLLER">
<div class="row">
<div class="col-md-6 " style="margin-top: 7px;">
<label>Select Class</label>
</div>
<div class="col-md-6 text-center">
<select class="form-control" title="Select Class"
name="fromClass" ng-change="EXAM_LIST_JSON(fromClass)"
ng-model="fromClass"
ng-options="fromClass.id as fromClass.course + ' ' + fromClass.section for fromClass in ALL_CLASS">
</select>
</div>
</div>
<div class="row" style="height: 10px"></div>
<div class="row">
<div class="col-md-6 " style="margin-top: 7px;">
<label>Select Examination</label>
</div>
<div class="col-md-6 text-center" >
<select class="form-control" name="examination"
ng-change="SUBJECT_LIST_IN_EXAM_JSON()"
ng-model="examination"
ng-options="examination.id as examination.name for examination in EXAM_LIST"></select>
</div>
</div>
控制器是
<script>
function MARK_ENTRY_CONTROLLER($scope, $http) {
$http.get("<%=request.getContextPath()%>/ALL_CLASS_JSON?AAdvisorId=${uid}").success(function(response) {
$scope.ALL_CLASS = response;
$scope.EXAM_LIST_JSON = function(id){
$http.get("<%=request.getContextPath()%>/EXAM_LIST_JSON?fromClass="+id)
.success(function(response) {
$scope.EXAM_LIST = response;
$scope.$apply();
});
}
});
}
</script>
在控制器中,数据列表是使用 json 格式从 json 文件中获取的。
请帮帮我..
bootstrap-select 隐藏所有 selector 并且 selector 的数据在执行命令 $('select').select选择器().
但是如何解决问题呢?
我遇到了类似的问题:
<select class="fontsize" data-style="btn-info" name="fontsize" ng-controller="fontSize">
<option data-ng-repeat="size in sizes" name="{{size}}" value="{{size}}">{{size}}</option>
</select>
还有我的控制器
app.controller('fontSize', function($scope, $http) {
$http.get("/getSelector/font-size")
.success(function(response) {
$scope.sizes = response.records;
// TODO: How to refresh the selectpicker after changing of scope?
});
});
您可以在收到数据后刷新select选择器:
$scope.$watch(function() {
$('.fontsize').selectpicker('refresh');
});
好的,希望对你有所帮助。
我正在创建一个 Web 应用程序,我在其中使用 bootstrap select 选择器 select.. 但我正在使用 angularjs 来填充 select 选择器.. 我有 2 select 其中一个的内容是根据第一个 select 值填充的,无需重新加载.. 我可以在没有 selectpicker 的情况下完美地工作,而它不会'使用 select 选择器时无法正常工作。我的代码是
<div class="form-group" data-ng-controller="MARK_ENTRY_CONTROLLER">
<div class="row">
<div class="col-md-6 " style="margin-top: 7px;">
<label>Select Class</label>
</div>
<div class="col-md-6 text-center">
<select class="form-control" title="Select Class"
name="fromClass" ng-change="EXAM_LIST_JSON(fromClass)"
ng-model="fromClass"
ng-options="fromClass.id as fromClass.course + ' ' + fromClass.section for fromClass in ALL_CLASS">
</select>
</div>
</div>
<div class="row" style="height: 10px"></div>
<div class="row">
<div class="col-md-6 " style="margin-top: 7px;">
<label>Select Examination</label>
</div>
<div class="col-md-6 text-center" >
<select class="form-control" name="examination"
ng-change="SUBJECT_LIST_IN_EXAM_JSON()"
ng-model="examination"
ng-options="examination.id as examination.name for examination in EXAM_LIST"></select>
</div>
</div>
控制器是
<script>
function MARK_ENTRY_CONTROLLER($scope, $http) {
$http.get("<%=request.getContextPath()%>/ALL_CLASS_JSON?AAdvisorId=${uid}").success(function(response) {
$scope.ALL_CLASS = response;
$scope.EXAM_LIST_JSON = function(id){
$http.get("<%=request.getContextPath()%>/EXAM_LIST_JSON?fromClass="+id)
.success(function(response) {
$scope.EXAM_LIST = response;
$scope.$apply();
});
}
});
}
</script>
在控制器中,数据列表是使用 json 格式从 json 文件中获取的。 请帮帮我..
bootstrap-select 隐藏所有 selector 并且 selector 的数据在执行命令 $('select').select选择器().
但是如何解决问题呢?
我遇到了类似的问题:
<select class="fontsize" data-style="btn-info" name="fontsize" ng-controller="fontSize">
<option data-ng-repeat="size in sizes" name="{{size}}" value="{{size}}">{{size}}</option>
</select>
还有我的控制器
app.controller('fontSize', function($scope, $http) {
$http.get("/getSelector/font-size")
.success(function(response) {
$scope.sizes = response.records;
// TODO: How to refresh the selectpicker after changing of scope?
});
});
您可以在收到数据后刷新select选择器:
$scope.$watch(function() {
$('.fontsize').selectpicker('refresh');
});
好的,希望对你有所帮助。