arguments for function call in angular expression

25 views
Skip to first unread message

John McPeek

unread,
Mar 6, 2014, 3:52:18 PM3/6/14
to ang...@googlegroups.com
Hi,
 I want to pass a scope variable to a function call i.e <div ng-click="doIt( importantInfo )">. The function doIt(importantInfo) gets called but the argument is undefined. Is it possible to pass arguments in an angular expression like that?

Thanks,

John

Orlando Cardoso

unread,
Mar 6, 2014, 4:24:46 PM3/6/14
to ang...@googlegroups.com
Sure.. not sure why it isn't working for you, but here's a plunker that does:  http://plnkr.co/edit/9qE4UOskiQIZDkDSQHxQ

John McPeek

unread,
Mar 6, 2014, 5:06:42 PM3/6/14
to ang...@googlegroups.com
Ahhhhh, I see what I was missing. I was doing it in the curly braces. So I can pass an argument in an attribute, but not in curly braces?


--
You received this message because you are subscribed to a topic in the Google Groups "AngularJS" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/angular/qRrpsYCIrGA/unsubscribe.
To unsubscribe from this group and all its topics, send an email to angular+u...@googlegroups.com.
To post to this group, send email to ang...@googlegroups.com.
Visit this group at http://groups.google.com/group/angular.
For more options, visit https://groups.google.com/groups/opt_out.

Orlando Cardoso

unread,
Mar 7, 2014, 10:42:52 AM3/7/14
to ang...@googlegroups.com
I'm not sure if there's a formal pattern, but it seems like you don't use curly braces when passing arguments to a directive (ng-click, ng-hide, etc), but do if referencing the scope from plain old html.
Reply all
Reply to author
Forward
0 new messages