angular $resouse服务
创建服务
var taskInstancesResource = function ($resource) { var resource = $resource('/ssc-cutover/rest/cutover/task/:id/groupInstance', { id: '@id' //ul地址上的参数 }, { query: { method : 'GET', //get isArray: true } } ); return resource; };
angular.module('ssc-cutover-task-viewer')
.factory('taskInstancesResource', ['$resource',taskInstancesResource])
使用:
1.在方法注入该服务
var Ctrl = function ($scope,$state,tasksResource,$mdDialog,taskService,$translate) {
2.
$scope.getTasksPromise = tasksResource.query($s {sorter:sorter}, function(data){ console.log(data); } ).$promise; $scope.getTasksPromise .then(function (data) { //请求成功 $scope.pageQuery.totalCount = data.length; $scope.tasks = data; })
/////////////////////////////////////////
remove:{
method:'DELETE',
url:'/ssc-cutover/rest/cutover/task/:id',
params:{
id:'@id'
},
isArray:false
}