Binding to complex objects in a directive

1,240 views
Skip to first unread message

Adam Bender

unread,
Aug 8, 2012, 7:46:40 PM8/8/12
to ang...@googlegroups.com
I have been trying to create a mildy complex directive that requires many properties to be bound for proper behavior. Ideally, I would like to be able to bind a single "model" object to a directive attribute which is accessible from inside the directive. After reading, and re-reading, the directive API it looks like creating a new scope and binding with "=" is the approach I should be taking. However, as this fiddle demonstrates the directive doesnt appear to be able to make use of the model object that is bound. Can someone shed some light on how to bind a complex object into a directive?

paulo.q...@gmail.com

unread,
Aug 15, 2012, 5:21:01 AM8/15/12
to ang...@googlegroups.com
use 
<custom data-local-model="model"></custom> 

Marco Alves

unread,
Aug 15, 2012, 6:04:55 AM8/15/12
to ang...@googlegroups.com, paulo.q...@gmail.com
This also the approach I'm using to wrap the fullcalendar widget in a directive

Jorge Sousa

unread,
Aug 15, 2012, 7:00:07 AM8/15/12
to ang...@googlegroups.com
Hi Adam, 

Follow Paulo reply and check the second paragraph of the directive documentation http://docs.angularjs.org/guide/directive

here's your fiddle updated with other possible working variations: 

Jorge

--
You received this message because you are subscribed to the Google Groups "AngularJS" group.
To post to this group, send email to ang...@googlegroups.com.
To unsubscribe from this group, send email to angular+u...@googlegroups.com.
Visit this group at http://groups.google.com/group/angular?hl=en.
 
 



--
-------------------------------
Jorge Sousa
Reply all
Reply to author
Forward
0 new messages