的Visual Studio 2013 - AngularJS基本问题 [英] Visual Studio 2013 - AngularJS Basic Issues

查看:147
本文介绍了的Visual Studio 2013 - AngularJS基本问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

1。问题

有关某种原因,我在Internet Explorer中/火狐得到一个旧版本的 list.html 文件,但只要我跑镀铬的应用,获得正确的输出(见下文)

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

输出Chrome浏览器:oi62.tinypic.com/2h7du9x.jpg

2。问题

这我创建的服务的JSON数据不被添加到表中的身体

测试消耗JSON数据 HTTP://oi59.tinypic。 COM / v5whus.jpg

非常感谢你提前。

我有以下code:

的index.html

 < HTML NG-应用=TodoApp的xmlns =htt​​p://www.w3.org/1999/xhtml>
< HEAD>
    <脚本SRC =脚本/ jQuery的-1.10.2.js>< / SCRIPT>
    <脚本SRC =脚本/ angular.js>< / SCRIPT>
    <脚本SRC =脚本/角resource.js>< / SCRIPT>
    <脚本SRC =脚本/角route.js>< / SCRIPT>
    <链接rel =stylesheet属性类型=文/ CSS的href =内容/ bootstrap.css/>
    <! - 自定义的Java脚本文件 - >
    <脚本SRC =脚本/ app.js>< / SCRIPT>
    <脚本SRC =脚本/ controllers.js>< / SCRIPT>
    <脚本SRC =脚本/ services.js>< / SCRIPT>
    <标题>惊人的Todo< /标题>
< /头>
<身体GT;
    < D​​IV CLASS =容器>
        < D​​IV NG-视图>< / DIV>
    < / DIV>
< /身体GT;
< / HTML>

app.js

  VAR TodoApp = angular.module(TodoApp,[
        ngRoute
        ngResource
        TodoApp.controllers
        TodoApp.services
])。
    配置(函数($ routeProvider){
        $ routeProvider。
            当('/',{控制器的listctrl,templateUrl:list.html'})。
            否则({redirectTo:'/'});
    });

list.html

 <表类=table表条纹表凝聚表悬停>
    <&THEAD GT;
        <第i藤< /第i
        <第i个优先级和LT; /第i
        <第i由于< /第i
    < / THEAD>
    <&TBODY GT;
        < TR NG重复=项待办事项>
            &所述; TD> {{item.Todo}}&下; / TD>
            &所述; TD> {{item.Priority}}&下; / TD>
            &所述; TD> {{item.DueDate}}&下; / TD>
        < / TR>
    < / TBODY>
< /表>

controllers.js

  angular.module('TodoApp.controllers',[])。
    控制器('的listctrl',函数($范围,$位置,todoApiService){
        $ scope.todos = todoApiService.getMyTodos.query();
});

services.js

  angular.module('TodoApp.services',[])。
    工厂('todoApiService',函数(){
        变种todoApi = {};        todoApi.getMyTodos =功能($资源){
            返回$资源('/ API /藤/:身份证',{ID:'@id'},{更新:{方法:把'}});
        };
    });


解决方案

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

简单地做一个硬刷新清除它,在IE它的<大骨节病>按Ctrl-R

火狐这是<大骨节病>按Ctrl-Shift-R键

1. Problem

For some reason I get in the Internet Explorer / Firefox an old version of the list.html file but as soon as I run the application with chrome, I get the proper output (see below).

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

Output Chrome : oi62.tinypic.com/2h7du9x.jpg

2. Problem

The JSON data from my created service isn't added to the body of the table.

Test to consume the JSON data : http://oi59.tinypic.com/v5whus.jpg

Thank you very much in advance.

I've got the following code:

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

解决方案

It sounds like a browser cache issue.

Simply do a hard-refresh to clear it, in IE it's Ctrl-R.

Firefox it's Ctrl-Shift-R.

这篇关于的Visual Studio 2013 - AngularJS基本问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆