【发布时间】:2019-10-12 07:26:15
【问题描述】:
我是angular1.5的初学者,我的问题是Meteor.call()返回的数据不显示在HTML中
这是我的代码:
hubs.js
class HubsController {
data = [];
constructor($scope, $uibModal) {
$scope.viewModel(this);
this.$scope = $scope;
this.$uibModal = $uibModal;
this.initViews();
this.subscribe('admin.verifiedBusinesses');
this.subscribe('admin.verifiedStars');
this.getData();
console.log('data', this.data);
}
...
getData() {
Meteor.call('warehouse.getAll', (err, data) => {
if (err) {
console.log(err);
}
// Initialize active routes.
this.data = data;
console.log(this.data); // data works fine
return data;
});
}
}
angular
.module('material-lite')
.controller('hubsDataController', ['$scope', '$uibModal', HubsController]);
数据在这里不起作用:
hubs.html
<div class="table-responsive" style="overflow-x: hidden" ng-controller="hubsDataController">
...
<tr ng-repeat="hubsData in data" class="table_row">
<td>{{ hubsData.name }}</td>
<td>
我希望 html 中的输出与从 getData 函数返回的 HubsController 类中的输出相同
【问题讨论】:
标签: angularjs meteor angular-meteor