This repository has been archived by the owner on Jun 19, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 7
/
demo.html
86 lines (74 loc) · 2.44 KB
/
demo.html
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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
<!doctype html>
<html ng-app="test">
<head>
<title>Solstice demo</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<body>
<div ng-controller="TestCtrl">
<h2>{{ text }}</h2>
<span ng-show="count">There are {{ count }} items on the default index.</span>
</div>
<h2>As a directive using default index</h2>
<ul solr-search rows="5" start="0" sort="id desc" fields="id,title">
<li ng-repeat="item in solr.results">{{ item.id }} - {{ item.title }}</li>
</ul>
<h2>Separate directive with custom index</h2>
<div solr-search rows="10" start="0" sort="id desc" fields="id,title"
index-url="http://solr1.newsfront.no/solr/newsfront-farmatid">
<span>There are {{ solr.count }} items on this index.</span>
<ul>
<li ng-repeat="item in solr.results">{{ item.id }} - {{ item.title }}</li>
</ul>
</div>
<h2>Separate controller and index</h2>
<div ng-controller="EquinoxCtrl">
<span ng-show="count">There are {{ count }} items on this index.</span>
<ul>
<li ng-repeat="item in results">{{ item.id }} - {{ item.title }}</li>
</ul>
</div>
<script src="//ajax.googleapis.com/ajax/libs/angularjs/1.6.6/angular.js"></script>
<script src="./dist/solstice.min.js"></script>
<script>
(function (ng) {
var app = ng.module('test', ['solstice']);
app.config(function (SolsticeProvider) {
SolsticeProvider.setEndpoint('http://solr1.newsfront.no/solr/newsfront-frontmag');
});
app.controller('TestCtrl', function ($scope, $timeout, Solstice) {
$scope.text = 'Solstice';
Solstice.search({
q: '*',
fl: 'id,title'
})
.then(function (_) {
var res = _.data.response;
$scope.count = res.numFound;
})
.catch(function (err) {
console.error(err);
});
});
app.factory('Equinox', function (Solstice) {
return Solstice.withEndpoint('http://solr1.newsfront.no/solr/newsfront-norskgolf');
});
app.controller('EquinoxCtrl', function ($scope, Equinox) {
Equinox.search({
q: '*',
fl: 'id,title',
rows: 7
})
.then(function (_) {
var res = _.data.response;
$scope.count = res.numFound;
$scope.results = res.docs;
})
.catch(function (err) {
console.error(err);
});
});
})(window.angular);
</script>
</body>
</html>