Giter Site home page Giter Site logo

Comments (7)

bianchimro avatar bianchimro commented on August 27, 2024

hi,
I don't think we need an option for a default value, as you can just set the selected option by setting your model to the desired default.

Does this solve your problem ?

from ionic-modal-select.

AdrienDC avatar AdrienDC commented on August 27, 2024

hi @bianchimro ,
I'm not sure to have totally understood how to do it. In my view I have :

`

Country
{{selectedCountry}}

{{option}}
``

with country containing the country array defined in the controller side

from ionic-modal-select.

bianchimro avatar bianchimro commented on August 27, 2024

Ok, to provide a default selection, in your controller you can just do this to provide an initial selection (for example "Italy" ):

$scope.selectedCountry = 'Italy';

and your modal select will start with "Italy" selected (of course the option should be in your array)

If you want more help, consider providing a codepen or plunkr.

Closing this for now (not really an issue with the library), but let me know if you can implement your use case.

from ionic-modal-select.

AdrienDC avatar AdrienDC commented on August 27, 2024

Thanks a lot @bianchimro, I didn't realized it was that simple 👍

from ionic-modal-select.

AdrienDC avatar AdrienDC commented on August 27, 2024

hi @bianchimro

Actually, I have an issue with defining like this. I applied the default selected country like you suggested but afterward I needed to update my modelname to $scope.data.selectedCountry instead of $scope.selectedCountry.

By doing this, I am not able to set the default value anymore and got this error from my controller: error TypeError: Cannot set property 'selectedCountry' of undefined

Any idea why?

This is only at initialization, when I update this property with ng-change it works perfectly...

from ionic-modal-select.

bianchimro avatar bianchimro commented on August 27, 2024

I needed to update my modelname to $scope.data.selectedCountry instead of $scope.selectedCountry.

mmh ... I don't understand why you had to do this.

difficult to help without seing the code. Can you post a codepen?

from ionic-modal-select.

AdrienDC avatar AdrienDC commented on August 27, 2024

yeah I had to do this in order to put back a default value of the modal select when my toggle is activated. Finally to solve this issue , I had to call a function in ng-init which initiate $scope.data.selectedCountry to my default value instead of doing it in the controller directly ... even if it's not recommended.

from ionic-modal-select.

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.