Comments (2)
You can adapt the template for your needs in autocomplete.js
:
{
...
template: '\
<div class="autocomplete {{ attrs.class }}" id="{{ attrs.id }}">\
<input\
type="text"\
ng-model="searchParam"\
placeholder="{{ attrs.placeholder }}"\
class="{{ attrs.inputclass }}"\
id="{{ attrs.inputid }}"/>\
<ul ng-show="completing && suggestions.length>0">\
<li\
suggestion\
ng-repeat="suggestion in suggestions | filter:searchFilter | orderBy:\'toString()\' track by $index"\
index="{{ $index }}"\
val="{{ suggestion }}"\
ng-class="{ active: ($index === selectedIndex) }"\
ng-click="select(suggestion)"\
ng-bind-html="suggestion | highlight:searchParam"></li>\
</ul>\
</div>'
...
}
In the <li>
you can make a sub-tag and style it like you want and access attributes of your suggestion e.g.
<img ng-src="suggestion.imageUrl"><div>{{suggestion.title}}</div>
If the template gets too long you can put it in a separate html file and then import it in autocomplete.js
with.
{
...
templateUrl: 'myTemplate.html',
...
}
It will also look prettier as pure HTML code without the \
on each new line.
from allmighty-autocomplete.
Hi @JustGoscha ,
Its works , Thanks for your time I have one small doubt
When a user click over any suggestion name must be filled in the input box and there must be some hidden field where I can store ID
For this I update
ng-click="select(suggestion.name,suggestion.id)"
and in autocomplete.js
$scope.select = function (suggestion,suggestionid) {
if (suggestion) {
$scope.selectPageId = suggestionid;
console.log(suggestionid);
$scope.searchParam = suggestion;
$scope.searchFilter = suggestion;
if ($scope.onSelect)
$scope.onSelect(suggestion);
}
watching = false;
$scope.completing = false;
setTimeout(function () {
watching = true;
}, 1000);
$scope.setIndex(-1);
};
and on the index.html page I add a new field
<input type="hidden" ng-modal="selectPageId" id="selectPageId" value=""/>
but its not passing the value to that field
So I update the code like this
$scope.select = function (suggestion,suggestionid) {
if (suggestion) {
$('#selectPageId').val( suggestionid );
console.log(suggestionid);
$scope.searchParam = suggestion;
$scope.searchFilter = suggestion;
if ($scope.onSelect)
$scope.onSelect(suggestion);
}
watching = false;
$scope.completing = false;
setTimeout(function () {
watching = true;
}, 1000);
$scope.setIndex(-1);
};
Which works but i know its a wrong way
from allmighty-autocomplete.
Related Issues (20)
- Not losing focus
- Support ng-disabled
- Pass id into on-type
- work like gmail or another email client
- Is it possible to show all list on initial focus or when suggestion is null?
- ng-enter search
- Closes the scrollable list of items if you click on scroll button HOT 2
- Read-Only & Disabled?
- suggestion problem
- Doesn't with array of objects HOT 1
- Add input-type=search (configureable)
- Disable spellcheck on mobile devices
- want to clear value in input type HOT 1
- How i can get the value ?
- tabindex not working
- Can multiple select?
- How I use ng-change?
- what modification required for using within ng-repeat
- getting console error on typing in autocomplete text box HOT 1
- any body implemented Add new item when no result found HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from allmighty-autocomplete.