Visual Studio 2013 - AngularJS基本问题

时间:2014-06-10 14:30:55

标签: 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' } });
        };
    });

1 个答案:

答案 0 :(得分:1)

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

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

Firefox它是 Ctrl-Shift-R

相关问题