Bri*_*tro 4 javascript angularjs angular-resource angularjs-ng-repeat
当我升级时,ng-repeat需要非常长的时间来加载并尝试显示更多内容框而没有$ resource提供的内容.
我已将问题缩小到1.1.0和1.1.1之间的更新.我查看了更改日志,但没有任何东西突然出现在我身上,但它必须在那里.
Changelog => https://github.com/angular/angular.js/blob/master/CHANGELOG.md#111-pathological-kerning-2012-11-26
此应用程序的存储库=> https://github.com/brianpetro/resume
目前我的角度看起来像:
app = angular.module("Resume", ["ngResource"])
app.factory "Entry", ["$resource", ($resource) ->
$resource("/entries")
]
@EntryCtrl = ["$scope", "Entry", ($scope, Entry) ->
$scope.entries = Entry.query()
]
Run Code Online (Sandbox Code Playgroud)
使用ng-repeat在多个视图上发生这种情况:
<html ng-app="Resume">
<div ng-controller="EntryCtrl">
<ul>
<li ng-repeat="entry in entries">
{{entry.title}}
</li>
</ul>
</div>
</html>
Run Code Online (Sandbox Code Playgroud)
这是AngularJS版本1.1.0:
这是AngularJS版本1.1.1:
你必须添加.json并不完全正确 - 至少不是从我从1.0.x切换到1.1.x时的经验.
为了使Rails应用程序返回json而不在Angular 1.1.x的URL中指定扩展名,您需要为http请求添加额外的标头:
myModule.config(['$httpProvider', function ($httpProvider) { $httpProvider.defaults.headers.common['X-Requested-With'] = 'XMLHttpRequest'; }]);
没有它,Rails默认情况下呈现整个HTML而不是返回JSON.
归档时间: |
|
查看次数: |
1387 次 |
最近记录: |