javascript - Visual Studio 2013 - AngularJS 基本问题

标签 javascript html json angularjs visual-studio-2013

1。问题

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

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

输出Chrome: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' } });
        };
    });

最佳答案

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

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

Firefox 是Ctrl-Shift-R

关于javascript - Visual Studio 2013 - AngularJS 基本问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24143669/

相关文章:

javascript - Angular JS 中的 $timeout

javascript - 状态没有更新

html - BeautifulSoup 和 prettify() 函数

json - Flutter JSON String/Int 命令

javascript - JAX RS - Jersey 文件传输,响应不应重定向

javascript - 如何解析位于不同 Web 服务器上的 XML 文件?

html - 我可以用 CSS 实现元素的垂直环绕吗?

javascript - 错误 : undefined is not an object (evaluating '$scope.inputcode.password' )

mysql - 如何使用Mysql数据库CONCAT AND Group Concat函数创建json数据

java - Jackson-jr 读取多态ArrayList