Skip to content
This repository was archived by the owner on May 29, 2019. It is now read-only.

Commit 4031e29

Browse files
ehteshamkafeelFoxandxss
authored andcommitted
docs(typeahead): add custom template demo
Closes #4412
1 parent 2c0ad03 commit 4031e29

File tree

1 file changed

+51
-1
lines changed

1 file changed

+51
-1
lines changed

Diff for: src/typeahead/docs/demo.html

+51-1
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,56 @@
1+
<style>
2+
.typeahead-demo .custom-popup-wrapper {
3+
position: absolute;
4+
top: 100%;
5+
left: 0;
6+
z-index: 1000;
7+
display: none;
8+
background-color: #f9f9f9;
9+
}
10+
11+
.typeahead-demo .custom-popup-wrapper > .message {
12+
padding: 10px 20px;
13+
border-bottom: 1px solid #ddd;
14+
color: #868686;
15+
}
16+
17+
.typeahead-demo .custom-popup-wrapper > .dropdown-menu {
18+
position: static;
19+
float: none;
20+
display: block;
21+
min-width: 160px;
22+
background-color: transparent;
23+
border: none;
24+
border-radius: 0;
25+
box-shadow: none;
26+
}
27+
</style>
28+
129
<script type="text/ng-template" id="customTemplate.html">
230
<a>
331
<img ng-src="http://upload.wikimedia.org/wikipedia/commons/thumb/{{match.model.flag}}" width="16">
432
<span ng-bind-html="match.label | typeaheadHighlight:query"></span>
533
</a>
634
</script>
7-
<div class='container-fluid' ng-controller="TypeaheadCtrl">
35+
36+
<script type="text/ng-template" id="customPopupTemplate.html">
37+
<div class="custom-popup-wrapper"
38+
ng-style="{top: position().top+'px', left: position().left+'px'}"
39+
style="display: block;"
40+
ng-show="isOpen() && !moveInProgress"
41+
aria-hidden="{{!isOpen()}}">
42+
<p class="message">select location from drop down.</p>
43+
44+
<ul class="dropdown-menu" role="listbox">
45+
<li ng-repeat="match in matches track by $index" ng-class="{active: isActive($index) }"
46+
ng-mouseenter="selectActive($index)" ng-click="selectMatch($index)" role="option" id="{{::match.id}}">
47+
<div typeahead-match index="$index" match="match" query="query" template-url="templateUrl"></div>
48+
</li>
49+
</ul>
50+
</div>
51+
</script>
52+
53+
<div class='container-fluid typeahead-demo' ng-controller="TypeaheadCtrl">
854

955
<h4>Static arrays</h4>
1056
<pre>Model: {{selected | json}}</pre>
@@ -21,4 +67,8 @@ <h4>Asynchronous results</h4>
2167
<h4>Custom templates for results</h4>
2268
<pre>Model: {{customSelected | json}}</pre>
2369
<input type="text" ng-model="customSelected" placeholder="Custom template" typeahead="state as state.name for state in statesWithFlags | filter:{name:$viewValue}" typeahead-template-url="customTemplate.html" class="form-control">
70+
71+
<h4>Custom popup templates for typeahead's dropdown</h4>
72+
<pre>Model: {{customPopupSelected | json}}</pre>
73+
<input type="text" ng-model="customPopupSelected" placeholder="Custom popup template" typeahead="state as state.name for state in statesWithFlags | filter:{name:$viewValue}" typeahead-popup-template-url="customPopupTemplate.html" class="form-control">
2474
</div>

0 commit comments

Comments
 (0)