【问题标题】:Visual Studio 2013 - AngularJS Basic IssuesVisual Studio 2013 - AngularJS 基本问题
【发布时间】:2023-03-21 03:15:01
【问题描述】:

1。问题

由于某种原因,我在 Internet Explorer / Firefox 中获得了旧版本的 list.html 文件,但是一旦我使用 chrome 运行应用程序,我就会得到正确的输出(见下文) .

输出 IE/Firefox:http://oi57.tinypic.com/2a9vgue.jpg

输出铬:oi62.tinypic.com/2h7du9x.jpg

2。问题

我创建的服务中的 JSON 数据未添加到表的正文中。

测试使用 JSON 数据:http://oi59.tinypic.com/v5whus.jpg

提前非常感谢您。

我有以下代码:

index.html

<html ng-app="TodoApp" xmlns="http://www.w3.org/1999/xhtml">
<head>
    <script src="Scripts/jquery-1.10.2.js"></script>
    <script src="Scripts/angular.js"></script>
    <script src="Scripts/angular-resource.js"></script>
    <script src="Scripts/angular-route.js"></script>
    <link rel="stylesheet" type="text/css" href="Content/bootstrap.css" />
    <!-- Custom Java Script files -->
    <script src="Scripts/app.js"></script>
    <script src="Scripts/controllers.js"></script>
    <script src="Scripts/services.js"></script>
    <title>Amazing Todo</title>
</head>
<body>
    <div class="container">
        <div ng-view></div>
    </div>
</body>
</html>

app.js

var TodoApp = angular.module("TodoApp", [
        "ngRoute",
        "ngResource",
        "TodoApp.controllers",
        "TodoApp.services"
]).
    config(function ($routeProvider) {
        $routeProvider.
            when('/', { controller: "listCtrl", templateUrl: 'list.html' }).
            otherwise({ redirectTo: '/' });
    });

list.html

<table class="table table-striped table-condensed table-hover">
    <thead>
        <th>Todo</th>
        <th>Priority</th>
        <th>Due</th>
    </thead>
    <tbody>
        <tr ng-repeat="item in todos">
            <td>{{item.Todo}}</td>
            <td>{{item.Priority}}</td>
            <td>{{item.DueDate}}</td>
        </tr>
    </tbody>
</table>

controllers.js

angular.module('TodoApp.controllers', []).
    controller('listCtrl', function ($scope, $location, todoApiService) {
        $scope.todos = todoApiService.getMyTodos.query();
});

services.js

angular.module('TodoApp.services', []).
    factory('todoApiService', function () {
        var todoApi = {};

        todoApi.getMyTodos = function ($resource) {
            return $resource('/api/Todo/:id', { id: '@id' }, { update: { method: 'PUT' } });
        };
    });

【问题讨论】:

  • 您是否尝试过清除浏览器缓存? Ctrl-R?我忘记了在 Firefox 中可能会有所不同
  • 问题 1 已解决 .. 无法想象这是由于一些临时数据。特别是,因为它发生在两个浏览器中..我真的很抱歉我不能投票给你的帖子.. :(
  • 添加了一个你可以标记为正确的答案!
  • 我会在解决第二个问题后立即这样做! :)

标签: javascript html json angularjs visual-studio-2013


【解决方案1】:

听起来像是浏览器缓存问题。

只需硬刷新即可清除它,在 IE 中是 Ctrl-R。

Firefox 它是 Ctrl-Shift-R。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-11-15
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多