Comments (9)
Try this:
$scope.$watch( 'methodDropDownOptions' , function() {
alert( 'hey, I am changed!' );
}, true );
from angular-multi-select.
Hi rajulkansara,
-
Not planning to do this, but you can get (almost) similar result by
combining the max-labels attribute and set the button width in the CSS. -
Validate your model before you process the data. For example, before you
save your form, you can loop over your input-model and check if at least
one of the model's tick-property is true.
On Wed, Jun 18, 2014 at 3:42 AM, rajulkansara [email protected]
wrote:
How to achieve fix width of dropdown no matter what is selected. If
selected options text width is big, it will show ... after truncated text.
If it is small it would show empty space.
2.A Dropdown with multiple select option where at least one option must
be selected. (A kind of Mix of Radio and Check-box Behavior)—
Reply to this email directly or view it on GitHub
#22.
from angular-multi-select.
For Number 2, i understood what you are advising. This has gave me hint that everytime any option is clicked i listen to to those changes and according i can achive alteast one option is selcted. But i did not find and event that is fire on every time i clicked on option. Do onChange will fire on model? or Any other specific event would fire on selecting or deselecting option?
from angular-multi-select.
There's no onChange event because you can simply use $watch in your
controller to watch changes in the input model $scope variable. The
directive will update the input model as you select / deselect a checkbox.
But the question is, why do you need to validate things on change? You can
always validate before you save your form.
On Jun 18, 2014 9:51 PM, "rajulkansara" [email protected] wrote:
For Number 2, i understood what you are advising. This has gave me hint
that everytime any option is clicked i listen to to those changes and
according i can achive alteast one option is selcted. But i did not find
and event that is fire on every time i clicked on option. Do onChange will
fire on model? or Any other specific event would fire on selecting or
deselecting option?—
Reply to this email directly or view it on GitHub
#22 (comment)
.
from angular-multi-select.
It is a UX. Validation on submit would waste my few click rather i want user to realize that he would have to have select at least one check box.
from angular-multi-select.
I see.. Yes you have a valid purpose there. Anyway, does my suggestion to detect changes using $watch solve your problem?
from angular-multi-select.
I tried watch and watchcollection both in my controller. None of them worked. On Checking and Unchecking i am not getting below alert. Let me know where i am wrong.
HTML
Method:
-----Controller
$scope.methodDropDownOptions = [ { name: "Option1", ticked: true },{ name: "Option2", ticked: false }, { name: "Option3", ticked: false }
$scope.$watchCollection('methodDropDownOptions', function() {
alert('hey, I am changed!');
});
from angular-multi-select.
Yes it is working. Thanks.
from angular-multi-select.
You're welcome, glad the directive works for you.
I'll consider that onChange() callback ( or onItemClick() perhaps ).. Looks like it'll be useful for some, as using $watch with objectEquality == true on complex / big object actually has an adverse memory and performance implications - as stated in AngularJS website.
I'm closing this issue now. Feel free to open a new one anytime. Cheers.
from angular-multi-select.
Related Issues (20)
- How to add tooltip for each dropdown element? HOT 9
- how to add default text when data is not bound to multiselect? HOT 1
- Reset doesn't set all values' 'ticked' property to false HOT 2
- output-model needn't be a compulsory attribute HOT 4
- Is there any angular 4 version of this available ? HOT 2
- Use same input-model to multiple multiselectors? HOT 4
- Select items from single group only
- XSS attack by option name
- Mutli select not support direction
- how to select all items loaded on the control??
- How to prevent .length == 'undefined' error when populating dropdown via on-open
- Filtering problem when grouped
- Grouping
- Issue injecting multi-select directive into another directive with same scope
- make filter clear button 'x' icon encoded
- Possible to launch dropdown from custom button?
- will it be possible to give remove option to the selected items in the ui HOT 1
- Search not working when grouping is enabled.
- Any ways to dynamically update helper-elements?
- Multiple elements selected when only one is clicked HOT 1
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 angular-multi-select.