Hi,

Thanks for your reply.

I've been trying to change my code so I use template instead of ng-include.

I am curious if you used the colorbox plugin in the past btw.

so in my view I have something like this

...
<button colorbox>open dialog</button>
...
,where 'colorbox' is a directive that launches the colorbox.


For my colorbox directive definition I have sth like this:


app.directive('colorbox', function(){
...

 element.click('bind', function(){
   $colorbox({
      href: 'path/to/my/colorboxcontentfile.html',
   })
 })

})

The above code works. So I have a bunch of html code inside the
'colorboxcontentfile.html', and
inside it there is a controller and a bunch of ng-models and other
angularjs directive.

The only problem is that the angularjs code is not being read ( so
ng-controllers, ng-models and other ng directives )
are not being read/compiled properly.

How can I get it to work?

Thanks
















2013/12/31 Daniel Tabuenca <[email protected]>

> 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-includeyou 
> 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
> element parameter 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 a topic in the
> Google Groups "AngularJS" group.
> To unsubscribe from this topic, visit
> https://groups.google.com/d/topic/angular/XbCkjuSMbjY/unsubscribe.
> To unsubscribe from this group and all its topics, 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.
>



-- 
JAKE KWON +1 (604) 655 3109
email: [email protected]

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