Using an isolate scope does not prevent you from accessing parent 
methods/properties, you can always use

scope.$parent.whateverMethod()

within the directive.

On Monday, July 28, 2014 1:24:06 PM UTC+5:30, Martin Spierings wrote:
>
> Hi all,
>
> I'm trying out something with directives which i haven't been using at all 
> yet (so bear with me). I'm trying to create my custom popup directive for 
> some easy popup dialogs. Now i'd like to keep my functionality from the 
> controller inside the popup as this is easier for me to maintain as i'm 
> gonna need some functions from the controller inside the popup and some 
> values too. Basically i'm retrieving JSON data and use the controller to 
> fill in my view on different locations. I've also got a submit-function in 
> my controller already, so you can see why i'd like to use the transclude on 
> my directive.
>
> Now i also want to add a title and a size of the popup to my directive 
> attributes so i can do something like this:
> <popup title="my title" width="large">
>     The contents of my popup and calling some stuff from the parent scope.
> </popup>
>
>
> Now in my template i want to use something like this (just quick n dirty):
> <div class="popup" ng-class="{size: popup-size}">
>     <div class="title">{{title}}</div>
>     <div class="content" ng-transclude="true"></div>
> </div>
>
> Of course i could make a separate directive for every popup i need but 
> that seems like a weird move.
>
> Now i know i can make a separate scope for the directive and add the title 
> or size there but then i lose the ability to use my parent scope functions 
> and values. And i'm not really looking to duplicate code or move it all 
> around just for my popups.
>
> So does anybody know how to do this?
> I'm pretty new to directives and i've searched around but couldn't find 
> anything that looks similar to my example of using both transclude with 
> additional scope values. And i also don't have a clue on how to 
> specifically target a certain directive to fill it in from my controller 
> (like popup[1].data ...).
>

-- 
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.

Reply via email to