Created
April 3, 2015 11:19
-
-
Save Avinava/8c0397d2e757352d1f08 to your computer and use it in GitHub Desktop.
Angular JS & SObject Remote : Part 1 Bringing Data to Page #NoControllers
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
<apex:page > | |
<apex:includeScript value="https://ajax.googleapis.com/ajax/libs/angularjs/1.3.14/angular.min.js"/> | |
<c:sObjectRemote /> | |
<script> | |
var vfApp = angular.module('vfApp',[]); | |
vfApp.controller('vfappController',function($scope){ | |
$scope.accounts = [] | |
$scope.getAccounts = function(){ | |
sObject.query('SELECT Id,Name,Site,Type,Phone FROM Account LIMIT 100',function(result){ | |
$scope.accounts = result; | |
$scope.$apply(); | |
}) | |
} | |
$scope.getAccounts(); | |
}); | |
</script> | |
<div ng-app="vfApp" ng-controller="vfappController"> | |
<apex:sectionHeader title="AngularJS" subtitle="AngularJS & SObject Remote"/> | |
<apex:pageBlock > | |
<!-- Borrow some styling from Pageblock table --> | |
<table class="list" border="0" cellpadding="0" cellspacing="0" id="contactsTable"> | |
<thead class="rich-table-thead"> | |
<tr class="headerRow "> | |
<th class="headerRow">Name</th> | |
<th class="headerRow">Site</th> | |
<th class="headerRow">Type</th> | |
<th class="headerRow">Phone</th> | |
</tr> | |
</thead> | |
<tbody> | |
<tr ng-repeat="a in accounts" class="dataRow" onmouseover="if (window.hiOn){hiOn(this);} " onmouseout="if (window.hiOff){hiOff(this);} " onblur="if (window.hiOff){hiOff(this);}" onfocus="if (window.hiOn){hiOn(this);}"> | |
<td class="dataCell">{{a.Name}}</td> | |
<td class="dataCell">{{a.Site}}</td> | |
<td class="dataCell">{{a.Type}}</td> | |
<td class="dataCell">{{a.Phone}}</td> | |
</tr> | |
</tbody> | |
</table> | |
</apex:pageBlock> | |
</div> | |
</apex:page> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment