The question is where do you want to access the DOM from? Accessing DOM 
from anything other than a directive is typically consider a bad practice 
in angular. If you are looking to animate, you should look at how to use 
ng-animate which is fairly simple to use and doesn’t require having access 
to the dom.

If you really need to access the dom for some reason, than that kind of 
logic is best encapsulated in a directive. Rather than using ng-include you 
could easily write your own colorbox directive. 

Directives sound intimidating but they are actually pretty simple. The most 
basic directive is really just a template:

app.directive('colorbox', function(){  return {
    template: "<div>Your Colorbox template goes here</div>" //You can use 
templateUrl instead 
});

So it is extremely simple to change your ng-include into a colorboxdirective 
(assuming the template is fixed).

A directive then gives you access to the DOM through a function the 
elementparameter passed into the link function:

app.directive('colorbox', function(){  return {
    template: "<div>Your Colorbox template goes here</div>",
    link: function(scope, element, attrs){
        //Do stuff with dom here:
        element.hide();    
    }
});

Writing directives like this is often a better idea than using ng-include. 
But like I said, if at all possible it is better to use ng-animate for 
animating.

On Tuesday, December 31, 2013 4:51:14 PM UTC-8, Jake K. wrote:


> Hello,
>
> I have a added a template that appears on a colorbox.
>
> the template is added with ng-include.
>
> I want to access some elements inside the template and perform 
> some animation.
>
> How can I access elements inside a template that was added with ng-include?
>
> Thanks
>
> PS: I may not be using the best method here, so feel free to make your 
> suggestion.
> What I basically have is a dialog box ( colorbox ) that appears once the 
> user clicks on a button.
> The dialog box contains a template ( using ng-include ), and now I want to 
> access its contents using dom.
>
>

-- 
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/groups/opt_out.

Reply via email to