我想通過angularjs獲得一個基本的$資源請求。我正在我的本地計算機上運行此操作。
但是,我得到了404。瀏覽器上的一個簡單的獲取請求加載了json。 這是chrome devtools顯示的請求。 (問:爲什麼是請求模式:選擇可以是這樣的問題?)
Request URL:http://example.com/api/rentable_properties.json
Request Method:OPTIONS
Status Code:404 Not Found
這裏是我的控制器,它正試圖發出請求:
'use strict';
angular.module('adminApp')
.factory('Property', function($resource)
{
return $resource('http://example.com/api/rentable_properties.json/:propertyId');
});
angular.module('adminApp')
.controller('PropertiesCtrl', function ($scope, Property, $location) {
$scope.properties = Property.query()
Stack Overflow認爲我的原始答案太短。 – JSager