Angularjs VisualStudio上的Apache Cordova示例';行不通

Angularjs VisualStudio上的Apache Cordova示例';行不通,angularjs,cordova,visual-studio-cordova,Angularjs,Cordova,Visual Studio Cordova,我按照msdn上的说明构建了ApacheCordova示例,但是当它运行时,我没有从输出中获得响应。输出类似于下图: 但无法向列表中添加/删除条目 我检查发现index.html包含以下行: <button class="templateLeft templateToggle" ng-class="{'checked': toDoItem.done, 'unchecked': !toDoItem.done}" ng-mousedown="

我按照msdn上的说明构建了ApacheCordova示例,但是当它运行时,我没有从输出中获得响应。输出类似于下图:

但无法向列表中添加/删除条目

我检查发现index.html包含以下行:

 <button class="templateLeft templateToggle" ng-class="{'checked': toDoItem.done, 'unchecked': !toDoItem.done}" ng-mousedown="toggleToDoDone(toDoItem)"></button>
  <button class="templateLeft templateRemove" ng-click="removeToDo(toDoItem)"></button>
我在这行上放置了一个断点:

angular.module('xPlat', ['xPlat.services', 'xPlat.controllers', 'xPlat.directives']);
并运行该应用程序,但该应用程序并未停止运行(显然,index.js未加载,如果加载,则不会运行)

为了查看文件是否存在于正确的位置,我运行应用程序,并在ripple emulator中加载文件后,将web浏览器的url更改为:

 http://localhost:4400/scripts/index.js
我可以在屏幕上看到index.js文本

为什么加载页面时不运行此函数

编辑2 在尝试并出错之后,我发现我在JS控制台上遇到了以下错误:

Failed to load resource: the server responded with a status of 404 (Not Found)
ripple.js (50,28958)


Error: [ng:areq] http://errors.angularjs.org/1.3.16/ng/areq?p0=ToDoCtrl&p1=not%20a%20function%2C%20got%20undefined
    at Error (native)
    at http://localhost:4400/scripts/frameworks/angular.min.js:6:417
    at Sb (http://localhost:4400/scripts/frameworks/angular.min.js:19:510)
    at La (http://localhost:4400/scripts/frameworks/angular.min.js:20:78)
    at http://localhost:4400/scripts/frameworks/angular.min.js:75:465
    at http://localhost:4400/scripts/frameworks/angular.min.js:57:178
    at q (http://localhost:4400/scripts/frameworks/angular.min.js:7:428)
    at M (http://localhost:4400/scripts/frameworks/angular.min.js:57:45)
    at g (http://localhost:4400/scripts/frameworks/angular.min.js:51:409)
    at g (http://localhost:4400/scripts/frameworks/angular.min.js:51:426)
angular.min.js (102,443)

从第一个错误中可以看出,某些文件丢失了,但是我如何才能找到丢失的文件呢?

我相信您还没有阅读该指南中的所有部分


请继续关注以下内容,您将在“添加数据模型”一节中提到的services.js中找到所需的函数。这里定义了数据模型和相关函数。

要在待办事项列表中添加条目,只需单击“需要做什么?”,开始键入,完成后按enter键。要删除条目,只需单击条目,您将看到左侧的“删除”按钮,单击该按钮,项目将消失,要将项目标记为“完成”,只需单击左侧的复选框

我刚刚用Android Ripple Nexus(Galaxy)运行了这个示例,它运行得很好。事实上,你得到了你所附的样本的第一页告诉我你很好去。我还得到了ripple上的404,但这并没有阻止样本运行(我必须调查该错误的原因)


最后,如果添加条目对您不起作用,请在解决方案资源管理器上双击www/scripts/controllers上的toDoCtrl.js文件,并在toDoCtrl.prototype.addToDo函数内设置一个断点,按F5并尝试添加条目,您应该在输入文本并按enter键后立即点击断点。

谢谢,我试着调试代码以找出为什么它不工作,我发现index.js中的函数没有被调用,我将更新问题并添加关于我做了什么和得到了什么的信息。添加了一些更详细的信息。您能看一下它并帮我提供一些建议吗?我自己还没有尝试过,但我想您在ripple emulator中调试时遇到了一个已知的问题。这就是与VisualStudio如何附加调试器相关的时间问题。尝试刷新Chrome页面,调试器将能够在deviceready事件中停止。然后再试一次,看看是否能击中断点。除了刷新,我们还可以在javascript控制台中运行window.location.reload()。
 http://localhost:4400/scripts/index.js
Failed to load resource: the server responded with a status of 404 (Not Found)
ripple.js (50,28958)


Error: [ng:areq] http://errors.angularjs.org/1.3.16/ng/areq?p0=ToDoCtrl&p1=not%20a%20function%2C%20got%20undefined
    at Error (native)
    at http://localhost:4400/scripts/frameworks/angular.min.js:6:417
    at Sb (http://localhost:4400/scripts/frameworks/angular.min.js:19:510)
    at La (http://localhost:4400/scripts/frameworks/angular.min.js:20:78)
    at http://localhost:4400/scripts/frameworks/angular.min.js:75:465
    at http://localhost:4400/scripts/frameworks/angular.min.js:57:178
    at q (http://localhost:4400/scripts/frameworks/angular.min.js:7:428)
    at M (http://localhost:4400/scripts/frameworks/angular.min.js:57:45)
    at g (http://localhost:4400/scripts/frameworks/angular.min.js:51:409)
    at g (http://localhost:4400/scripts/frameworks/angular.min.js:51:426)
angular.min.js (102,443)