Created
December 24, 2014 10:17
-
-
Save florianhoehn/4d9ea55a13e30f7f9743 to your computer and use it in GitHub Desktop.
Create with ngRemote
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!-- 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