forked from mailtoharshit/Angular
-
Notifications
You must be signed in to change notification settings - Fork 0
/
AngularJSDemoController.cls
37 lines (31 loc) · 1.05 KB
/
AngularJSDemoController.cls
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
public with sharing class AngularJSDemoController{
public String AccountList { get; set; }
//Subclass : Wrapper Class
public class Accountwrap {
//Static Variables
public string id;
public string name;
public string Phone;
//Wrapper Class Controller
Accountwrap() {
Phone = '';
}
}
//Method to bring the list of Account and Serialize Wrapper Object as JSON
public static String getlstAccount() {
List < Accountwrap > lstwrap = new List < Accountwrap > ();
List < account > lstacc = [SELECT Id, Name, Phone
FROM Account limit 100
];
for (Account a: lstacc) {
Accountwrap awrap = new Accountwrap();
awrap.id = a.id;
awrap.name = a.name;
if (a.Phone != null) {
awrap.Phone = a.Phone;
}
lstwrap.add(awrap);
}
return JSON.serialize(lstwrap);
}
}