0
저는 AngularJS에 처음 왔으며 여기에 질문이 있습니다.
내 CRUD 작업에 $resource
을 사용하고 있습니다.
나는 현재 이런 코드, 내가 공장 수준의 API에 대한 특정 URL을 제공하지 않으려는 의미, 내 UserRoleService
제네릭을하고 싶습니다
angular.module("dopAngular.services")
.factory("UserRoleService", ["$resource",
function ($resource) {
return $resource("api/UserRoleApi", {}, {
query: { method: "GET", isArray: true },
create: { method: "POST" },
get: { method: "GET" },
remove: { method: "DELETE" },
update: { method: "PUT" }
});
}]);
//below is the code in my controller
UserRoleService.query(function (data) {
vm.UserRoleLookups = data;
});
있습니다.
지금
angular.module("dopAngular.services")
.factory("UserRoleService", ["$resource",
function ($resource, url) {
return $resource(url, {}, {
query: { method: "GET", isArray: true },
create: { method: "POST" },
get: { method: "GET" },
remove: { method: "DELETE" },
update: { method: "PUT" }
});
}]);
내 질문은 내가 내 컨트롤러에해야 할 일입니다, 내 코드를 조금 수정?