gpt4 book ai didi

javascript - 数据上没有显示任何内容

转载 作者:行者123 更新时间:2023-12-02 15:06:48 25 4
gpt4 key购买 nike

出于某种原因,当您在 main.html 中看到将数据放入表中时,我的数据不会显示。这是一个 meteor 应用程序,所以不用担心 Angular ,它已经使用节点安装了,因为我也我的电脑上有 meteor 。我关注了this教程

main.html:

<body>
<div ng-controller="PartiesListCtrl">
<table border = 1>
<tr ng-repeat = "data in parties">
<td>{{data.name}}</td>
<td>{{data.description}}</td>
</tr>
</table>
</div>
</body>

index.html:

<body ng-app="socially">
<div ng-include src="'main.html'"></div>
</body>

app.js:

if (Meteor.isClient) {
angular.module('socially', ['angular-meteor']);

angular.module('socially').controller('PartiesListCtrl',["$scope", function ($scope) {
$scope.parties = [
{
'name': 'Dubstep-Free Zone',
'description': 'Can we please just for an evening not listen to dubstep.'
},
{
'name': 'All dubstep all the time',
'description': 'Get it on!'
},
{
'name': 'Savage lounging',
'description': 'Leisure suit required. And only fiercest manners.'
}
];
}]
);
}

最佳答案

您的代码应如下所示。

angular.module('socially', ['angular-meteor'])
.controller('PartiesListCtrl',["$scope", function ($scope) {
$scope.parties = [
{
'name': 'Dubstep-Free Zone',
'description': 'Can we please just for an evening not listen to dubstep.'
},
{
'name': 'All dubstep all the time',
'description': 'Get it on!'
},
{
'name': 'Savage lounging',
'description': 'Leisure suit required. And only fiercest manners.'
}
];
}]
);

更改

删除 angular.module('socially') 的第二个实例并直接使用 .controller 或将其分配给某个变量,然后使用 Controller ,如下所示。

var socially = angular.module('socially', ['angular-meteor']);
socially.controller('PartiesListCtrl',["$scope", function ($scope) {
//Your controller code goes here.
}]);

如果不起作用,请告诉我。

angular.module('socially', [])
.controller('PartiesListCtrl',["$scope", function ($scope) {
$scope.parties = [
{
'name': 'Dubstep-Free Zone',
'description': 'Can we please just for an evening not listen to dubstep.'
},
{
'name': 'All dubstep all the time',
'description': 'Get it on!'
},
{
'name': 'Savage lounging',
'description': 'Leisure suit required. And only fiercest manners.'
}
];
}]
);
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.23/angular.min.js"></script>
<body ng-app="socially">
<div ng-controller="PartiesListCtrl">
<table border = 1>
<tr ng-repeat = "data in parties">
<td>{{data.name}}</td>
<td>{{data.description}}</td>
</tr>
</table>
</div>
</body>

关于javascript - 数据上没有显示任何内容,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35076394/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com