【发布时间】:2016-03-15 03:10:36
【问题描述】:
我一直在尝试做的是显示 ng-repeat 的内容。问题是我不能使用双花括号{{ value }}。
如果你还没有尝试过,让我解释一下,如果你使用 Laravel 5.2,这个表达式 {{ value }} 将找到一个名为 $value 的变量。显然,使用双花括号{{ value }} 不会引用ng-repeat 的内容,即使有如下表达式。
<tr ng-repeat="value in values"></tr>
所以,我通常依赖ng-bind,但ng-bind 似乎不像往常那样与ng-repeat 一起工作。
我的代码如下所示。
<div ng-app="angularApp" ng-controller="TableController as tc">
<input type="text" ng-model="searchBox">
<table style="width:100%;">
<tr>
<th>Student ID</th>
<th>Name</th>
</tr>
<tr ng-repeat="student in students | filter:searchBox">
{{ student.name }}//This causes an error, indicating "Use of undefined constant student"
<td ng-bind="student.student_id"></td>
<td ng-bind="student.name"></td>
</tr>
</table>
</div>
<script type="text/javascript">
angular.module('angularApp')
.controller('TableController', function(){
this.data = {
students: [
@foreach($students as $student)
"{{ $student }}",
@endforeach
]
};
});
</script>
$students 是一个数组,包含名为 student 的 SQL 对象。这来自 Laravel 的控制器功能。
你看到我做错了什么吗?任何建议将不胜感激!
【问题讨论】:
-
需要更改angular JS的分隔符
标签: php angularjs laravel laravel-5