我有以下代码我有多个对象作为回报如何获取这些请帮助检查下面的代码和图像文件
<tr>
<td colspan="" width="6%">
<center>
<input type="checkbox" name="check_yes[]" value="yes">
</center>
</td>
<td colspan="" width="6%">
<center>
<input type="checkbox" name="check_no[]" value="no">
</center>
</td>
</tr>
//我的下降
.then(response => {
this.jobCategories = response.data;
console.log(response.data);
this.jobCategories.categories.sort(function(a,b){
a.child_categories.sort();
return a.category_name > b.category_name;
});
this.selectedCategoryL1 = this.jobCategories.categories[0];
this.selectedCategoryL2 = this.selectedCategoryL1.child_categories[0];
});
子类别
<select class="form-control ng-pristine ng-valid ng-not-empty ng-touched" name="category" id="category" ng-model="postjobcustomerCtrl.selectedCategoryL1" ng-options="category.category_name for category in postjobcustomerCtrl.jobCategories.categories | orderBy:'category_name' track by category.category_name" ng-change="postjobcustomerCtrl.changeChildCategory()" aria-invalid="false" style=""></select>
答案 0 :(得分:0)
请看下面的内容,我认为这是个问题 如果上面的代码在你的控制器中,这个。 selectedCategoryL1不再是词汇$ scope'this'。您需要将此设置为方法之外的var或使用$ scope。 selectedCategoryL1。
var vm = this;
//or use $scope.selectedCategoryL1
.then(response => {
this.jobCategories = response.data;
console.log(response.data);
this.jobCategories.categories.sort(function(a, b) {
a.child_categories.sort();
return a.category_name > b.category_name;
});
//or replace vm with $scope.
vm.selectedCategoryL1 = this.jobCategories.categories[0];
vm.selectedCategoryL2 = this.selectedCategoryL1.child_categories[0];
});