我想在我的视图中显示$scope.predicate
和$scope.reverse
值(在<p>
标签中)。似乎使用{{ }}
表达式不起作用。
应用程序.js:
var app = angular.module('testApp', []);
app.controller('TestController', function($scope,$http ){
var vm = this;
vm.rezdata = [];
$http.get("some rest resource...")
.then(function(response) {
vm.rezdata = response.data;
$scope.predicate = 'username';
$scope.reverse = true;
});
});
HTML:
<body ng-app="testApp">
<h1>Users table </h1>
<table class="table table-striped" ng-controller="TestController as test">
<p> Sorting predicate {{predicate}}; reverse = {{reverse}} </p>
<thead>
<tr>
<th>#</th>
<th>
Username
</th>
...
</tr>
</thead>
<tbody>
<tr ng-repeat="datafinal in test.rezdata" >
<td>{{ datafinal.id}} </td>
<td>{{datafinal.username}} </td>
...
</tr>
</tbody>
</table>
</body>