Comments (7)
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.
hi @bianchimro ,
I'm not sure to have totally understood how to do it. In my view I have :
`
Country {{selectedCountry}}
with country containing the country array defined in the controller side
from ionic-modal-select.
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.
Thanks a lot @bianchimro, I didn't realized it was that simple 👍
from ionic-modal-select.
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.
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.
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)
- How can i open the model from controller?
- Bug in Search HOT 4
- enableBackdropDismiss
- Divider
- ionic1: item is selected but is not show the selected item
- I have an ionic popover with a form. In that form i want to use ionic model select for country selection.But when i open the ionic model select it apears behind the ionic popover back drop,Is there any solution? HOT 1
- Ionic model select on ionic popover HOT 2
- modal-open class not removed from body element HOT 4
- ReferenceError: require is not defined HOT 4
- Manual unselect
- Text of Ok button is setted hardcoded HOT 2
- Change default modal template? HOT 3
- Display element of its choice belonging to the ng-model
- Image selection
- Error: [$parse:syntax] Syntax Error: Token ':' not a primary expression at column 1 of the expression HOT 1
- Call Reset Function Outside of Modal HOT 3
- no cancel callback ?
- Select All button for multiple selection
- This plugin still working in IONIC 3? HOT 1
- Error: collection-repeat tried to compute the height of repeated elements HOT 4
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 ionic-modal-select.