我想在不同的网址上发布帖子操作。当我试着写不同的工厂时,我想它可以识别另一家工厂。
Service.js
var app = angular.module("ServiceApp", ["ngResource"]);
app.factory('GetPortfolios', function ($resource) {
return $resource("http://localhost:61347/api/PortfolioManager/GetPortfolios/", {}, {
});
app.factory('GetOrders', function ($resource) {
return $resource("http://localhost:61347/api/PortfolioManager/GetPortfolioOrders/");
});
});
App.js
var app = angular.module("UiApp", ["ServiceApp"]);
app.controller("PortFolioController", function ($scope, GetPortfolios) {
$scope.Portfolios = GetPortfolios.query({ pmid: 2 });
console.log($scope.Portfolios);
});
app.controller("OrderController", function ($scope, GetOrders) {
$scope.Orders = GetOrders.query({ id: 25 });
console.log(Orders);
});
答案 0 :(得分:1)
在Service.js内,第一个工厂缺少结束 })
paranthesis,请检查更新后的Service.js
var app = angular.module("ServiceApp", ["ngResource"]);
app.factory('GetPortfolios', function ($resource) {
return $resource("http://localhost:61347/api/PortfolioManager/GetPortfolios/", {}, {});
});
app.factory('GetOrders', function ($resource) {
return $resource("http://localhost:61347/api/PortfolioManager/GetPortfolioOrders/");
});