7 this.fetch = function() {
9 self.url = '/g/' + self.function_name + '/' + self.args + '?callback=JSON_CALLBACK';
10 $xhr('JSON', self.url, function(code, response) {
12 self.response = response;
16 this.clear = function() {
32 this.keys = function(h) {
33 if ( angular.isArray(h) ) h = h[0];
35 for(i in h) if (h.hasOwnProperty(i))
43 CRM.$inject = ['$xhr'];
45 <div ng:controller="CRM">
46 <input type="hidden" name="function_name" value="CRM_search" size="20"/>
47 <label for="args">username:
48 <input type="text" name="args" value="test" size="10"/>
50 <button ng:click="fetch()">fetch</button>
51 <button ng:click="clear()">clear</button>
52 <b ng:show="url && ! code">loading {{url}}</b>
53 <b ng:show="response">{{response.length}} results</b>
55 <div style="font-size: 80%; float: right" ng:show="response">
58 <li ng:repeat="c in keys(response)" ng:show="columns.indexOf(c) < 0" ng:click="columns.push(c)">{{c}}
62 <table ng:show="response">
64 <th ng:repeat="c in columns" ng:click="columns.$remove(c)">{{c}}</th>
66 <tr ng:repeat="u in response">
67 <td ng:repeat="c in columns">{{u[c]}}</td>
70 <input type=checkbox name=debug value=1>