首页 > 代码库 > angular--ngResource的简单使用

angular--ngResource的简单使用

service.factory(‘domainResource‘,function($resource){    return $resource(‘/domainsInfo/:id‘,{id:‘@id‘})});service.factory(‘resultset‘,function($resource){    return $resource(‘/resultset/:key/:objName‘,{key:‘@key‘,objName:‘@objName‘})});service.factory(‘objValuesResult‘,function($resource){    return $resource(‘/objValuesResult/:key/:property/:valueBlob‘,{key:‘@key‘,property:‘@property‘,valueBlob:‘@valueBlob‘})});service.factory(‘test‘,function($resource){    return $resource(‘/test‘,{})});

获得data:

$scope.KeyObjects =resultset.query({key:key});

 存:

      var updateOneRecord = new resultset({});      updateOneRecord[‘key‘] = resu.key;      updateOneRecord[‘objectid‘] = resu.objectid;      updateOneRecord[‘column‘] = resu.column;       updateOneRecord[‘property‘] = resu.property;       updateOneRecord[‘labels‘] = $scope.labelMap;      updateOneRecord[‘values‘] = $scope.valueMap;      resultset.save(updateOneRecord);

删除:

      var delMyRecord = new resultset({key:resu.key,objName:resu.column});       resultset.delete(delMyRecord);

 

angular--ngResource的简单使用