Git Product home page Git Product logo

Comments (7)

 avatar commented on June 16, 2024

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.

 avatar commented on June 16, 2024

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.

 avatar commented on June 16, 2024

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.

smiderle avatar smiderle commented on June 16, 2024

Thanks for the answer. But I have more than one on a view. I'll try something similar.

from angucomplete-alt.

smiderle avatar smiderle commented on June 16, 2024

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.

ghiden avatar ghiden commented on June 16, 2024

I think people want both clear all and individual options.
I'll add this feature based on @Leocrest #61

from angucomplete-alt.

jlhffmn avatar jlhffmn commented on June 16, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.