Skip to content

Instantly share code, notes, and snippets.

@florianhoehn
Created December 24, 2014 10:17
Show Gist options
  • Save florianhoehn/4d9ea55a13e30f7f9743 to your computer and use it in GitHub Desktop.
Save florianhoehn/4d9ea55a13e30f7f9743 to your computer and use it in GitHub Desktop.
Create with ngRemote
<!-- DEFINITION REMOTEOBJECTS -->
<apex:remoteObjects jsNamespace="TestNamespace">
<apex:remoteObjectModel name="Account"
fields="Id, Name, SomeCustomField__c"/>
</apex:remoteObjects>
<!-- INCLUDE ANGULARJS -->
<apex:includeScript value="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.14/angular.min.js"/>
<!-- NGREMOTEOBJECTS -->
<c:ngRemote remoteObjectNamespace="TestNamespace"
remoteObjects="Account" />
<!-- ACTUAL ANGULARJS APP -->
<script type="text/javascript">
var ngApp = angular.module('ngApp', ['ngRemote']);
ngApp.controller('demoController',
['$scope',
'AccountService',
function($scope,
AccountService) {
var accountToCreate = {};
accountToCreate.Name = 'TestName';
accountToCreate.SomeCustomField__c = 'Some value';
AccountService.create(accountToCreate).then(function(result) {
if(result) {
console.log(result)
}
}, function(error) {
console.log(error);
});
}]);
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment