What I've been trying to do is to show the contents of ng-repeat. The problem is that I can't use the double curly braces, {{ value }}.
In case you haven't tried this, let me explain that this expression, {{ value }}, is going to find a variable named $value if you use Laravel 5.2. Apparently, using double curly braces, {{ value }}, won't refer to the content of ng-repeat, even if there is an expression like the following one.
<tr ng-repeat="value in values"></tr>
So, I usually rely on ng-bind, but ng-bind doesn't seem to work with ng-repeat as it usually does.
My code looks like this.
<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 is an array, containing SQL objects called student. This comes from a Laravel's controller function.
Do you see anything I'm doing wrong? Any advice will be appreciated!
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire