Skip to content

Instantly share code, notes, and snippets.

@msrivastav13
Last active August 29, 2015 14:22
Show Gist options
  • Save msrivastav13/e67dd98dfeec8ed20a21 to your computer and use it in GitHub Desktop.
Save msrivastav13/e67dd98dfeec8ed20a21 to your computer and use it in GitHub Desktop.
<apex:page controller="MyAccCtrl" showHeader="false" sidebar="false" standardStylesheets="false" docType="html-5.0">
<apex:stylesheet value="//maxcdn.bootstrapcdn.com/bootstrap/3.3.4/css/bootstrap.min.css"/>
<apex:includeScript value="//ajax.googleapis.com/ajax/libs/angularjs/1.3.0-beta.11/angular.min.js"/>
<apex:remoteObjects jsNamespace="RemoteObjectModel">
<apex:remoteObjectModel name="Account" jsShorthand="acc" fields="Name,Phone"></apex:remoteObjectModel>
</apex:remoteObjects>
<script>
var app = angular.module("ngApp", []);
app.controller("ContactCtrl", ["$scope", function($scope) {
$scope.accs= [];
$scope.getaccounts= function() {
Visualforce.remoting.Manager.invokeAction(
'{!$RemoteAction.MyAccCtrl.myAccounts}',
function(result, event) {
$scope.accs= result;
$scope.$apply();
});
}
$scope.addAccount = function() {
var acctDetails = { Name: $scope.newname, Phone: $scope.newPhone};
// Call create()
var accnew = new RemoteObjectModel.acc(acctDetails);
accnew.create();
$scope.newname = "";
$scope.newPhone = "";
$scope.getaccounts();
}
}]);
</script>
<div class="container" ng-app="ngApp" ng-controller="ContactCtrl" ng-init="getaccounts()">
<div class="page-header">
<h1> Angular + Bootstrap + Visualforce
<small>Dallas Meet up</small>
</h1>
</div>
<h2>
Create New Account
</h2>
<p>
<input ng-model="newname" size="15" placeholder="Type Account Name" class="form-control"/>&nbsp;
<input ng-model="newPhone" size="15" placeholder="Enter Phone No" class="form-control"/><br />
<button ng-click="addAccount()" class="btn btn-primary btn-lg btn-block">
Add &amp; Save New Account
</button>
</p>
<div class="list-group" ng-repeat="acc in accs">
<a href="/{{acc.Id}}" target="_blank" class="list-group-item">
<h4 class="list-group-item-heading">{{acc.Name}}</h4>
<p class="list-group-item-text">phone :{{acc.Phone}}
<br/>
{{acc.website}}
</p>
</a>
</div>
</div>
</apex:page>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment