Javascript 为什么ng repeat start和ng repear end不能正常工作?
我正在尝试用Angular JS(也使用Laravel)构建一个简单的评论应用程序,下面是一个代码:Javascript 为什么ng repeat start和ng repear end不能正常工作?,javascript,angularjs,Javascript,Angularjs,我正在尝试用Angular JS(也使用Laravel)构建一个简单的评论应用程序,下面是一个代码: <div ng-controller="CommentController"> <div ng-repeat-start="comment in comments" class="comment"> <h3>Comment {{ comment.id }} <small>by {{ comment.author }}<
<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>
这是输出:
注释1由Artem的评论
评论人
尖刻的评论
如果这对您有帮助,我将使用AngularJS 1.2.22。您的JSON对象可能格式错误 根据您试图实现的目标,应采用以下格式:
$scope.comments = [
{ id: 1, author: "Artem", text: "Angular comment" },
{ id: 2, author: "Other", text: "Other Angular comment" }
];
您的JSON对象可能格式错误 根据您试图实现的目标,应采用以下格式:
$scope.comments = [
{ id: 1, author: "Artem", text: "Angular comment" },
{ id: 2, author: "Other", text: "Other Angular comment" }
];
您的JSON对象可能格式错误 根据您试图实现的目标,应采用以下格式:
$scope.comments = [
{ id: 1, author: "Artem", text: "Angular comment" },
{ id: 2, author: "Other", text: "Other Angular comment" }
];
您的JSON对象可能格式错误 根据您试图实现的目标,应采用以下格式:
$scope.comments = [
{ id: 1, author: "Artem", text: "Angular comment" },
{ id: 2, author: "Other", text: "Other Angular comment" }
];
1.这里不需要ng repeat start和ng repeat end指令。这些指令背后有什么特殊原因吗 2.只需使用ng repeat即可实现这一点 如果您想使用这两个指令。试试这个
<div ng-controller="CommentController">
<div ng-repeat-start="comment in comments" class="comment">
<h3>Comment {{ comment.id }} <small>by {{ comment.author }}</small></h3>
</div>
<div ng-repeat-end></div>
<p>{{ comment.text }}</p>
</div>
</div>
1.这里不需要ng repeat start和ng repeat end指令。这些指令背后有什么特殊原因吗 2.只需使用ng repeat即可实现这一点 如果您想使用这两个指令。试试这个
<div ng-controller="CommentController">
<div ng-repeat-start="comment in comments" class="comment">
<h3>Comment {{ comment.id }} <small>by {{ comment.author }}</small></h3>
</div>
<div ng-repeat-end></div>
<p>{{ comment.text }}</p>
</div>
</div>
1.这里不需要ng repeat start和ng repeat end指令。这些指令背后有什么特殊原因吗 2.只需使用ng repeat即可实现这一点 如果您想使用这两个指令。试试这个
<div ng-controller="CommentController">
<div ng-repeat-start="comment in comments" class="comment">
<h3>Comment {{ comment.id }} <small>by {{ comment.author }}</small></h3>
</div>
<div ng-repeat-end></div>
<p>{{ comment.text }}</p>
</div>
</div>
1.这里不需要ng repeat start和ng repeat end指令。这些指令背后有什么特殊原因吗 2.只需使用ng repeat即可实现这一点 如果您想使用这两个指令。试试这个
<div ng-controller="CommentController">
<div ng-repeat-start="comment in comments" class="comment">
<h3>Comment {{ comment.id }} <small>by {{ comment.author }}</small></h3>
</div>
<div ng-repeat-end></div>
<p>{{ comment.text }}</p>
</div>
</div>
您的控制器似乎未注册。你应该这样做:
myApp.controller('CommentController', ['$scope', function($scope) {
$scope.comments = [
{ id: 1, author: "Artem", text: "Angular comment" },
{ id: 2, author: "Other", text: "Other Angular comment" }
];
}]);
仅将myApp更改为您的模块名称。您的控制器似乎未注册。你应该这样做:
myApp.controller('CommentController', ['$scope', function($scope) {
$scope.comments = [
{ id: 1, author: "Artem", text: "Angular comment" },
{ id: 2, author: "Other", text: "Other Angular comment" }
];
}]);
仅将myApp更改为您的模块名称。您的控制器似乎未注册。你应该这样做:
myApp.controller('CommentController', ['$scope', function($scope) {
$scope.comments = [
{ id: 1, author: "Artem", text: "Angular comment" },
{ id: 2, author: "Other", text: "Other Angular comment" }
];
}]);
仅将myApp更改为您的模块名称。您的控制器似乎未注册。你应该这样做:
myApp.controller('CommentController', ['$scope', function($scope) {
$scope.comments = [
{ id: 1, author: "Artem", text: "Angular comment" },
{ id: 2, author: "Other", text: "Other Angular comment" }
];
}]);
仅将myApp更改为您的模块名称。@zorza提到的内容也可能是正确的 除非您在代码的下面某个地方使用了如下内容:
myApp.controller('CommentController', 'CommentController');
@zorza提到的可能也是正确的 除非您在代码的下面某个地方使用了如下内容:
myApp.controller('CommentController', 'CommentController');
@zorza提到的可能也是正确的 除非您在代码的下面某个地方使用了如下内容:
myApp.controller('CommentController', 'CommentController');
@zorza提到的可能也是正确的 除非您在代码的下面某个地方使用了如下内容:
myApp.controller('CommentController', 'CommentController');
在这种情况下使用ng repeat start和ng repeat end是否有特殊原因?在一个div上简单的ng repeat不够吗?首先,我使用了ng repeat,同样的问题。ru试图实现的只是Mat的回答,您的JSON/模型格式不正确或缺少一些属性。您也可以使用一个简单的
ng repeat
。)在这种情况下使用ng repeat start和ng repeat end是否有特殊原因?在一个div上简单的ng repeat不够吗?首先,我使用了ng repeat,同样的问题。ru试图实现的只是Mat的回答,您的JSON/模型格式不正确或缺少一些属性。您也可以使用一个简单的ng repeat
。)在这种情况下使用ng repeat start和ng repeat end是否有特殊原因?在一个div上简单的ng repeat不够吗?首先,我使用了ng repeat,同样的问题。ru试图实现的只是Mat的回答,您的JSON/模型格式不正确或缺少一些属性。您也可以使用一个简单的ng repeat
。)在这种情况下使用ng repeat start和ng repeat end是否有特殊原因?在一个div上简单的ng repeat不够吗?首先,我使用了ng repeat,同样的问题。ru试图实现的只是Mat的回答,您的JSON/模型格式不正确或缺少一些属性。您也可以使用一个简单的ng repeat
。)