Angularjs 角度-can';无法使用$http获取数据

Angularjs 角度-can';无法使用$http获取数据,angularjs,Angularjs,我用Grunt和yeoman构建我的angularjs应用程序 我的主机在example.com上,我的api是example.com/api 然后我尝试使用$http如下: $http.get('/api/posts').success(function (data) { console.log(data) //the data is my index.html code }) 有人能告诉我为什么我得到的数据是我的index.html代码吗?我怎样才能修好它 谢谢 当您尝试访问

我用Grunt和yeoman构建我的angularjs应用程序

我的主机在
example.com
上,我的api是
example.com/api

然后我尝试使用
$http
如下:

$http.get('/api/posts').success(function (data) {
    console.log(data)    //the data is my index.html code
})
有人能告诉我为什么我得到的数据是我的index.html代码吗?我怎样才能修好它


谢谢

当您尝试访问不存在或无法直接访问的页面('/api/posts')时,您将返回index.html代码,请尝试查看

example.com/api/posts/


在浏览器地址栏上,查看返回的内容。

这是否与
$routeProvider
配置相关?我设置了
否则({redirectTo:'/'})
是,这可能是原因。