You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to ang...@googlegroups.com
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
Pawel Kozlowski
unread,
Jan 27, 2013, 3:29:19 AM1/27/13
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to ang...@googlegroups.com
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.
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.
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to ang...@googlegroups.com
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.
Stéphane Vasseur
unread,
Feb 18, 2013, 11:25:35 AM2/18/13
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to ang...@googlegroups.com
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
Nick Barton
unread,
Apr 18, 2013, 2:43:41 AM4/18/13
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to ang...@googlegroups.com
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
Lucas Antoine
unread,
Apr 21, 2013, 7:26:56 PM4/21/13
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to ang...@googlegroups.com
This solution doesn't work for me.
Thomas Chille
unread,
Jun 6, 2014, 7:08:56 AM6/6/14
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to ang...@googlegroups.com
This works for me:
.directive('mySelect', [
'$timeout'
($timeout) ->
restrict: 'E'
templateUrl: '/shared/select.html'
replace: yes
scope:
ngModel: '='
ngChange: '&'
nameProp: '='
options: '='
link: (scope, element, attrs) ->
scope.$watch 'ngModel', ->
scope.selected = scope.ngModel?[scope.nameProp]
scope.select = (option) ->
scope.ngModel = option
$timeout ->
$scope.ngChange()
])
Nozel Rosario
unread,
Jun 4, 2015, 3:38:51 PM6/4/15
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message