1 (function(angular
, $, _
) {
3 angular
.module('api4').factory('crmApi4', function($q
) {
4 var crmApi4 = function(entity
, action
, params
, index
) {
5 // JSON serialization in CRM.api4 is not aware of Angular metadata like $$hash, so use angular.toJson()
6 var deferred
= $q
.defer();
8 var backend
= crmApi4
.backend
|| CRM
.api4
;
9 if (_
.isObject(entity
)) {
10 // eval content is locally generated.
12 p
= backend(eval('('+angular
.toJson(entity
)+')'), action
);
14 // eval content is locally generated.
16 p
= backend(entity
, action
, eval('('+angular
.toJson(params
)+')'), index
);
20 deferred
.resolve(result
);
23 deferred
.reject(error
);
26 return deferred
.promise
;
28 crmApi4
.backend
= null;
29 crmApi4
.val = function(value
) {
37 })(angular
, CRM
.$, CRM
._
);