Comments (7)
Doesn't look like you can.
It would be nice if you could pass a function from your controller into the clear-selected or some other attribute and have angucomplete add a listener to that function to clear the string when the function is called.
from angucomplete-alt.
I created a Pull Request for this:
#61
You can use the branch on my fork in the meantime if you like in your bower.json:
"angucomplete-alt": "https://github.com/Leocrest/angucomplete-alt.git#feat/clear"
Branch can be found here:
https://github.com/Leocrest/angucomplete-alt/tree/feat/clear
Basically in your controller if you have a button calling a function called addSelected
you can do something like:
$scope.addSelected = function (role) {
//Complete app specific logic
...
//Then
$rootScope.$broadcast('angucomplete-alt:clearSearch');
};
from angucomplete-alt.
Quick note: This approach will clear the inputs on ALL angucomplete fields. So if you have more than one on a view this may not be exactly what you want. In my case there is only one angucomplete on the view so it doesn't matter.
from angucomplete-alt.
Thanks for the answer. But I have more than one on a view. I'll try something similar.
from angucomplete-alt.
I made as small adjustment, and it worked fine with multiple directive in a view.
$rootScope.$broadcast('angucomplete-alt:clearSearch', { target: 'idAutocomplete' });
and in angucomplete-alt
scope.$on('angucomplete-alt:clearSearch', function (event, args) {
if(scope.id == args.target){
scope.searchStr = null;
clearResults();
}
});
Thanks.
from angucomplete-alt.
I think people want both clear all and individual options.
I'll add this feature based on @Leocrest #61
from angucomplete-alt.
Note that the syntax has changed. See the description at the bottom of the angucomplete-alt home page:
$scope.$broadcast('angucomplete-alt:clearInput', 'autocomplete-1');
from angucomplete-alt.
Related Issues (20)
- AJAX errors are sometimes ignored (httpErrorCallbackFn and remote-url-error-callback)
- Autocomplete-alt
- Console error message
- Angucomplete-alt
- Filtered result disappearing In IE if the data is large
- Tap on Autocomplete-alt dropdown causes updating results on android HOT 6
- Angucomplete-alt : one error results from the $injector being unable to resolve a required dependency after adding the angucomplete-alt module to my Angular App file, e.g.
- After adding the angucomplete-alt module to my Angular App file, I got an error 'being unable to resolve a required dependency' on console. What's wrong?
- Duplicate ng-focus on input
- .title not working when selected-object is a function
- How to pass index into selected-object HOT 1
- If data comes in binary format in name filed then it is going to be ng-invalid.
- Error: [$injector:modulerr]
- Unable to get the data with proper format in HTML in angular js
- Using arrow down starts from the second item HOT 1
- Using arrows may leave inconsistent value in the input field HOT 1
- RemoteUrlErrorCallback is undefined
- Address Auto Complete not working on Mozilla Firefox but working on Chrome and IE
- Custom search doesn't trigger function within controller HOT 1
- *.md
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 angucomplete-alt.