我是angularjs的新手,只是想用它来创建一个CRUD应用程序。
我的代码是这样的http://jsfiddle.net/fpnna/1/
我使用apache作为when服务器,当图灵在
$locationProvider.html5mode(true);然后得到
uncaught TypeError: Object #<Ic> has no method 'html5mode' from testApp 当我点击“添加新的”路径时,更改为"/new“,但得到错误
404 The requested URL /new was not found on this server.知道我哪里做错了吗?
我翻了一遍官方手册,没弄明白。
提前谢谢。
发布于 2013-05-09 21:20:19
您有几个问题,首先,在jsfiddle中,您不需要body标记,而且您有多个body标记。此外,您的小提琴有两个ng-app,路由定义不正确(例如,应该是/new ),无效的ng-view结束标记,应该只有一个。你应该用No wrap in head包括javascript,最后它是html5Mode,模式上有一个大写的M,并且你的部分urls不存在,也没有定义为本地脚本。
我建议你使用plunkr,因为它允许你添加其他本地文件,即你的部分不存在于小提琴中。
我已经解决了这个问题r:http://plnkr.co/edit/A23Fxn9Ji02TGZ0jouZR?p=preview
angular.module('testApp', []).
config(function ($routeProvider, $locationProvider) {
$locationProvider.html5Mode(true); // case is important
$routeProvider.
when("/", {
templateUrl: "list.html"
}).
when("/new", { // make sure and use absolute link to route
templateUrl: "edit.html"
})
})
function testCtrl($scope) {
$scope.persons = [{
name: "X"
}, {
name: "Y"
}, {
name: "Z"
}]
}和html:
<body ng-controller="testCtrl" >
<div class="main-nav"> <a href="new">Add Me</a>
</div>INDEX
<div >
<div ng-view>
</div>
</div>
</body>请查看文档和教程以了解设置项目的基础知识。http://docs.angularjs.org/guide/bootstrap
https://stackoverflow.com/questions/16462307
复制相似问题