Code Monkey home page Code Monkey logo

Comments (8)

DhruvPrakash avatar DhruvPrakash commented on July 21, 2024

I too was in need of this feature. In the end I simply modified the dropdownMenu directive to get what I needed. I'm still a novice at angular so my approach may seem kinda clunky, but this is what I did:
1)I added another property to the isolate scope of the dropdownMenu directive called showDropDown:

 scope: {
        dropdownMenu: '=',
        dropdownModel: '=',
        dropdownOnchange: '&',
        showDropDown: '='  //I added this part
      }

2)I added an ng-show to the template variable and set it equal to showDropDown

template = "<ul ng-show='showDropDown' class='dropdown'>\n    <li ng-repeat='item in dropdownMenu'\n        class='dropdown-item'\n        dropdown-item-label='labelField'\n        dropdown-menu-item='item'>\n    </li>\n</ul>";

3)In my controller I had a true/false variable called dropdownEnabled(my controller and not the directives controller property):

$scope.dropdownEnabled = true;// or false depending on if you want to enable or disable the dropdown

4)In my html where I needed the dropdown I added the new property show-drop-down apart from the other existing properties and set it equal to dropdownEnabled.

 <a href=''    show-drop-down='dropdownEnabled '  dropdown-menu="ddMenuOptions" dropdown-model="ddMenuSelected"  dropdown-onchange="dropDownItem(selected)">Open Dropdown</a>

from angular-dropdowns.

jseppi avatar jseppi commented on July 21, 2024

@DhruvPrakash thanks for the answer!
If you'd like to submit a pull request with your modifications I'd be happy to include it into the module.
One small request: change the showDropDown property to be called dropdownDisabled and change ng-show='showDropDown' to ng-hide='dropdownDisabled'

from angular-dropdowns.

yarivdev avatar yarivdev commented on July 21, 2024

anything new? this would be a very nice addition.

from angular-dropdowns.

jseppi avatar jseppi commented on July 21, 2024

Pull requests are welcome!

from angular-dropdowns.

jseppi avatar jseppi commented on July 21, 2024

As of version 1.2.0, the dropdown-disabled setting has been added thanks to @Chinokao.

from angular-dropdowns.

asso1985 avatar asso1985 commented on July 21, 2024

Seems like not working to me, is not disabled if i put dropdown-disabled="true" or false

from angular-dropdowns.

jseppi avatar jseppi commented on July 21, 2024

@asso1985 can you make a jsFiddle showing your problem? It seems to work on my example page http://jseppi.github.io/angular-dropdowns/ (click the Disable All) button.

from angular-dropdowns.

asso1985 avatar asso1985 commented on July 21, 2024

Just checked my package.json and found out this :

"name": "angular-dropdowns",
"version": "1.1.0",

Seems like i'm running version "version": "1.1.0", that might be the problem.

That was the problem, sorry.

from angular-dropdowns.

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.