gpt4 book ai didi

javascript - Angular JS 从 1.1.0 升级到 1.1.1 后失败

转载 作者:搜寻专家 更新时间:2023-11-01 05:12:59 25 4
gpt4 key购买 nike

当我升级时,ng-repeat 需要非常长的时间来加载并尝试显示更多内容框,而没有 $resource 提供的内容。

我已将问题缩小到 1.1.0 和 1.1.1 之间的更新。我查看了更新日志,但我没有突然想到是罪魁祸首,但它一定在那里。

更新日志 => https://github.com/angular/angular.js/blob/master/CHANGELOG.md#111-pathological-kerning-2012-11-26

此应用程序的存储库 => https://github.com/brianpetro/resume

目前我的 Angular 看起来像:

app = angular.module("Resume", ["ngResource"])

app.factory "Entry", ["$resource", ($resource) ->
$resource("/entries")
]

@EntryCtrl = ["$scope", "Entry", ($scope, Entry) ->
$scope.entries = Entry.query()
]

这发生在使用 ng-repeat 的多个 View 上:

<html ng-app="Resume">
<div ng-controller="EntryCtrl">
<ul>
<li ng-repeat="entry in entries">
{{entry.title}}
</li>
</ul>
</div>
</html>

这是 AngularJS 1.1.0 版: This is AngularJS version 1.1.0这是 AngularJS 版本 1.1.1: This is AngularJS version 1.1.1

最佳答案

您必须添加 .json 并不完全正确 - 至少从我从 1.0.x 切换到 1.1.x 时的经验来看不是这样。

为了使 Rails 应用程序在 Angular 1.1.x 的 URL 中返回不带 specyfing 扩展名的 json,您需要为 http 请求添加额外的 angular header :

myModule.config(['$httpProvider', function ($httpProvider) {    $httpProvider.defaults.headers.common['X-Requested-With'] = 'XMLHttpRequest';}]);

否则 Rails 默认呈现整个 HTML 而不是返回 JSON。

Github issue reflecting that

关于javascript - Angular JS 从 1.1.0 升级到 1.1.1 后失败,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15811062/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com