我正在尝试使用 Angular JS(也使用 Laravel)构建一个简单的评论应用程序,这里是一个代码:
<div ng-controller="CommentController">
<div ng-repeat-start="comment in comments" class="comment">
<h3>Comment {{ comment.id }} <small>by {{ comment.author }}</small></h3>
<p>{{ comment.text }}</p>
</div>
<div ng-repeat-end></div>
</div>
</div>
这是我的 JS 文件:
function CommentController($scope) {
$scope.comments = [
{ id: 1 },
{ author: "Artem" },
{ text: "Angular comment" }
];
}
这是输出:
的评论 1
Artem 的评论
评论者
Angular 评论
我正在使用 AngularJS 1.2.22,如果这可以帮助你。
最佳答案
您的 JSON 对象可能格式错误。
根据您想要实现的目标,它应该采用以下格式:
$scope.comments = [
{ id: 1, author: "Artem", text: "Angular comment" },
{ id: 2, author: "Other", text: "Other Angular comment" }
];
关于javascript - 为什么 ng-repeat-start 和 ng-repeat-end 无法正常工作?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25307456/