CRM-14725 - Add Angular service wrapper for CRM.api3
authorTim Otten <totten@civicrm.org>
Thu, 22 May 2014 01:44:11 +0000 (18:44 -0700)
committerTim Otten <totten@civicrm.org>
Thu, 22 May 2014 01:44:11 +0000 (18:44 -0700)
templates/CRM/Core/Page/Angular.tpl

index ca531b944d7929c833b5c966f24a04b819b4c85b..1ff32b35d9e520b73fe2baf7d739d92c34227e02 100644 (file)
         });
       }
     ]);
+    crmApp.factory('crmApi', function(){
+      return function(entity, action, params, message) {
+        // JSON serialization in CRM.api3 is not aware of Angular metadata like $$hash
+        return CRM.api3(entity, action, eval('('+angular.toJson(params)+')'), message);
+      };
+    });
   })();
 </script>