Re: [angular.js] directive compile function and accessing the scope

5,004 views
Skip to first unread message

Vojta Jína

unread,
Jun 11, 2012, 11:12:36 PM6/11/12
to ang...@googlegroups.com
This is not possible, during compile function, there is no scope. You should do this kind of stuff in the linking phase.

V.

On Tue, May 22, 2012 at 12:32 PM, Eddie <co...@rocketmail.com> wrote:
How do you access the directive attributes (which points to the parent scope) in the compile function?

In the linking function it is easy.

Eg: <div bs-dialog show="showDialog">

I am using code like: var show=$rootScope.$eval(tAttrs.show)

and to set it to false
$rootScope.$eval(tAttrs.show + ' = false')

In linking function I could use accessor:
scope.show() and scope.show(false) 
but not in the compile function?

--
You received this message because you are subscribed to the Google Groups "AngularJS" group.
To view this discussion on the web visit https://groups.google.com/d/msg/angular/-/CWJ9iapXcHAJ.
To post to this group, send email to ang...@googlegroups.com.
To unsubscribe from this group, send email to angular+u...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/angular?hl=en.

Dalci Bagolin

unread,
Jun 12, 2012, 8:46:09 AM6/12/12
to ang...@googlegroups.com
I need to create a table in a directive wich titles of colomns is based in an array that is in $scope controller.

If I use the link functions the data are not bind.

How can I do this?


Dalci 

john....@mokimobility.com

unread,
Mar 17, 2013, 8:13:19 AM3/17/13
to ang...@googlegroups.com
Dalci,

Did you ever find a good way to do this, i know it was a long time ago?
I also am trying to achieve the same thing. Basically trying to build a table view directive and will have different amount of columns and data from different resources. I have a directive where he table html gets transcluded into the directive, and using a controller directive instead of a linking or compile function my headers and td's are rendered from my main scope controller.

Alexandru Rada

unread,
May 5, 2013, 1:05:45 AM5/5/13
to ang...@googlegroups.com
Hey guys, did you find the solution to pass the array to the compile function? what would be a solution to this? I have the same issue....

John Walker

unread,
Jun 13, 2013, 3:23:24 AM6/13/13
to ang...@googlegroups.com
My solution was to use ng-grid from the ui team
Reply all
Reply to author
Forward
0 new messages