Thanks, this worked for me :)
On Thursday, 18 April 2013 12:13:41 UTC+5:30, Nick Barton wrote:
>
> This reply might be a bit random but I hope this helps. Something like
> this in a directive
>
>
> var num = 0; // compute this value somehow
> var evalStr = attrs.ngModel + '=' + num.toString();
> // update the bound scope variable and if exists call the change function
> if (typeof attrs.ngChange != 'undefined')
> {
> evalStr += ';'+attrs.ngChange;
> }
> scope.$apply(evalStr);
>
> Hope this helps
>
> On Monday, 18 February 2013 16:25:35 UTC, Stéphane Vasseur wrote:
>>
>> I'd be interested to know if you found a workaround because I was looking
>> for a way to trigger the ngChange event too.
>> Thanks
>>
>> On Sunday, January 27, 2013 4:41:00 AM UTC-5, Mahbub wrote:
>>>
>>> Thanks Pawel for your reply. I needed a generic listener for a number of
>>> controls on the change event so that i can check the object equality and
>>> save data when that happens. I guess I'll change the plan a bit.
>>>
>>> On Sunday, January 27, 2013 2:29:19 PM UTC+6, Pawel Kozlowski wrote:
>>>>
>>>> Hi!
>>>>
>>>> Ng-change is not the right path here as this directive is meant to be
>>>> used for reacting on _model_ changes as you've rightly observed.
>>>> You should be registering general DOM event handlers in a directive.
>>>>
>>>> If you are looking for the inspiration regarding bootstrap drop-down
>>>> directives I would suggest having a look at the "Dropdown Toggle"
>>>> directive from the
>>>> http://angular-ui.github.com/bootstrap/
>>>> Sources here:
>>>> https://github.com/angular-ui/bootstrap/blob/master/src/dropdownToggle/dropdownToggle.js
>>>>
>>>>
>>>> The idea here is that you extract to the directive common parts
>>>> (rendering a dropdown, toggling its visibility etc.) while still
>>>> allowing people to specify content of their drop down. This way people
>>>> can simply bind click events to the content at will.
>>>>
>>>> Cheers,
>>>> Pawel
>>>>
>>>> On Sun, Jan 27, 2013 at 9:07 AM, Mahbub <[email protected]> wrote:
>>>> > Hi,
>>>> >
>>>> > I was wondering how to implement a dropdown directive which will have
>>>> the
>>>> > ngChange event like a normal select has.
>>>> >
>>>> > This is what i have so far http://jsfiddle.net/mahbub/GfCTU/19/ . I
>>>> know
>>>> > ngChange requires ngModel controller but how do i trigger the
>>>> onChange on
>>>> > that dropdown when value changes.
>>>> >
>>>> > Any help is greatly appreciated.
>>>> >
>>>> > Thanks
>>>> >
>>>> > --
>>>> > You received this message because you are subscribed to the Google
>>>> Groups
>>>> > "AngularJS" group.
>>>> > To post to this group, send email to [email protected].
>>>> > To unsubscribe from this group, send email to
>>>> > [email protected].
>>>> > Visit this group at http://groups.google.com/group/angular?hl=en-US.
>>>> >
>>>> >
>>>>
>>>>
>>>>
>>>> --
>>>> Question? Send a fiddle
>>>> (http://jsfiddle.net/pkozlowski_opensource/Q2NpJ/) or a plunk
>>>> (http://plnkr.co/)
>>>> Need help with jsFiddle? Check this:
>>>>
>>>> http://pkozlowskios.wordpress.com/2012/08/12/using-jsfiddle-with-angularjs/
>>>>
>>>>
>>>> Looking for UI widget library for AngularJS? Here you go:
>>>> http://angular-ui.github.com/
>>>>
>>>
--
You received this message because you are subscribed to the Google Groups
"AngularJS" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/angular.
For more options, visit https://groups.google.com/d/optout.