用AngularJS 1.2破坏的简单重新三角形示例
我正在做一个基本的用AngularJS 1.2破坏的简单重新三角形示例,angularjs,restangular,Angularjs,Restangular,我正在做一个基本的restanglar示例,它在AngularJS 1.1上工作,但是在1.2上,发送了REST请求,接收了数据,但表没有正确显示 我在这里通读了一些关于从1.1升级到1.2的文章,但我没有看到这个问题,因为示例非常简单,没有明确使用ngRoute、隔离作用域或自定义指令 HTML <!DOCTYPE html> <html ng-app="countries"> <head> <meta charset="utf-8"
restanglar
示例,它在AngularJS 1.1
上工作,但是在1.2
上,发送了REST
请求,接收了数据,但表没有正确显示
我在这里通读了一些关于从1.1升级到1.2
的文章,但我没有看到这个问题,因为示例非常简单,没有明确使用ngRoute
、隔离作用域或自定义指令
HTML
<!DOCTYPE html>
<html ng-app="countries">
<head>
<meta charset="utf-8" />
<title>REST Country Example</title>
<link rel="stylesheet" href="//maxcdn.bootstrapcdn.com/bootstrap/3.3.1/css/bootstrap.min.css">
<script src="//code.angularjs.org/1.2.27/angular.min.js"></script>
<script src="//code.angularjs.org/1.2.27/angular-resource.min.js"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/underscore.js/1.7.0/underscore-min.js"></script>
<script src="//cdn.rawgit.com/mgonto/restangular/master/dist/restangular.min.js"></script>
<script src="app.js"></script>
</head>
<body ng-controller="mainCtrl">
<div>
<h2>Restangular Example with RESTCountries.eu</h2>
<input type="text" ng-model="search" class="search-query" placeholder="Search">
<table class="table table-responsive table-striped">
<thead>
<tr>
<th>Country</th>
<th>Capital</th>
<th>Code</th>
</tr>
</thead>
<tbody>
<tr ng-repeat="country in countries | filter:search | orderBy:'name'">
<td>{{country.name}}</td>
<td>{{country.capital}}</td>
<td>{{country.alpha2Code}}</td>
</tr>
</tbody>
</table>
</div>
</body>
</html>
你知道为了让1.2上的程序正常工作,有什么遗漏/错误吗
干杯,我以前从来没有用过
restanglar
。看起来它返回了1.2版本的承诺,而不是数据,我可以通过以下小修改加载数据:
app.controller('mainCtrl', function($scope, Restangular) {
Restangular.all('all').getList().then(function(result) {
$scope.countries = result;
});
});
aaah。。。你说得对,我在1.2中忽略了移除承诺展开。由于fa6e411d,承诺拆封已被删除。自1.2.0-rc.3以来,它一直被弃用。它无法再打开。已删除两个方法:$parseProvider.unwrapPromises$parseProvider.logPromiseWarnings谢谢您的帮助。
app.controller('mainCtrl', function($scope, Restangular) {
Restangular.all('all').getList().then(function(result) {
$scope.countries = result;
});
});