我试图用ASP.NET Web Api设置基本的restangular,
var app = angular.module('app', [
'restangular'
]);
app.config(function (RestangularProvider) {
RestangularProvider.setBaseUrl('/api');
RestangularProvider.setRequestSuffix('.json');
});
var app = angular.module('app');
app.controller('home', ['Restangular', home]);
function home(Restangular) {
var test= Restangular.all('/HelloWorld');
alert(test);
}
它没有达到我设置的网络API Web api - localhost / api / HelloWorld
答案 0 :(得分:1)
您需要将完整的网址添加到setBaseUrl中,如下所示:
app.config(function (RestangularProvider) {
RestangularProvider.setBaseUrl('http:/localhost/api');
RestangularProvider.setRequestSuffix('.json');
});
答案 1 :(得分:0)
这应该有效
app.config(function (RestangularProvider) {
RestangularProvider.setBaseUrl('/api/');
});
var app = angular.module('app');
app.controller('home', ['Restangular', home]);
function home(Restangular) {
var test= Restangular.all('HelloWorld').getList();
alert(test);
}