Default priority for custom directive?

Showing 1-14 of 14 messages
Default priority for custom directive? water...@gmail.com 2/20/13 12:08 PM
Say I create a custom directive without assigning a number to its "priority" property, does it get a default priority? If so, what is it? Thanks.
Re: [AngularJS] Default priority for custom directive? Pawel Kozlowski 2/20/13 12:10 PM
AFAIK default priority is ZERO. Which means that any directive that
specifies non-zero value for priority will execute before.

Cheers,
Pawel

On Wed, Feb 20, 2013 at 9:08 PM,  <water...@gmail.com> wrote:
> Say I create a custom directive without assigning a number to its "priority"
> property, does it get a default priority? If so, what is it? Thanks.
>
> --
> 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 ang...@googlegroups.com.
> To post to this group, send email to ang...@googlegroups.com.
> Visit this group at http://groups.google.com/group/angular?hl=en-US.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>



--
Looking for bootstrap-based widget library for AngularJS?
http://angular-ui.github.com/bootstrap/
Re: [AngularJS] Default priority for custom directive? water...@gmail.com 2/20/13 12:19 PM
Thanks for your prompt answer, Pawel. It would be nice if this piece of information is written into the section about directives in the official docs. 


On Wednesday, February 20, 2013 12:10:15 PM UTC-8, Pawel Kozlowski wrote:
AFAIK default priority is ZERO. Which means that any directive that
specifies non-zero value for priority will execute before.

Cheers,
Pawel

On Wed, Feb 20, 2013 at 9:08 PM,  <water...@gmail.com> wrote:
> Say I create a custom directive without assigning a number to its "priority"
> property, does it get a default priority? If so, what is it? Thanks.
>
> --
> 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 angular+u...@googlegroups.com.
> To post to this group, send email to ang...@googlegroups.com.
> Visit this group at http://groups.google.com/group/angular?hl=en-US.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>



--
Looking for bootstrap-based widget library for AngularJS?
http://angular-ui.github.com/bootstrap/
Re: [AngularJS] Default priority for custom directive? Corinne Krych 2/28/13 12:28 PM
Hello Angular team,

On the priority topic, is it possible to define a custom directive and to make it execute after ng-switch directive? Which value should I use for my directive priority?

thks,
Corinne

To unsubscribe from this group and stop receiving emails from it, send an email to ang...@googlegroups.com.

To post to this group, send email to ang...@googlegroups.com.
Visit this group at http://groups.google.com/group/angular?hl=en-US.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

Re: [AngularJS] Default priority for custom directive? Dan Kang 2/28/13 12:38 PM
Hi Corinne,

Since ng-switch directive doesn't have priority specified (thus uses the default priority of 0), any negative value should do.  I'm not sure this is reliable from version to version though.

Dan
Re: [AngularJS] Default priority for custom directive? Corinne Krych 2/28/13 12:49 PM
Actually I've just looked at the code:
var ngSwitchWhenDirective = ngDirective({
  transclude: 'element',
  priority: 500,
  require: '^ngSwitch',
...

But still doesn't sort out my issue

Corinne


To unsubscribe from this group and stop receiving emails from it, send an email to ang...@googlegroups.com.

To post to this group, send email to ang...@googlegroups.com.
Visit this group at http://groups.google.com/group/angular?hl=en-US.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

Re: [AngularJS] Default priority for custom directive? Dan Kang 2/28/13 1:16 PM
What is the problem you're trying to solve?  Most execution order issues are not affected by compile-time priority.
Re: [AngularJS] Default priority for custom directive? Corinne Krych 3/1/13 1:12 AM
Hello Dan

The problem I was trying to sort was an issue with list refresh in
jQuery mobile. I know from reading the mailing list that using jQuery
mobile is not the best recommanded approach but to me jqm is solving
all my needs on the mobile ui aspect.

Main issue with jqm/angular is always around refresh. Angular resolves
its HTML but then you need to tell jqm to do its rendering. For list
you use a listview('refresh') method. I've wrapped those refresh in a
directive jqm-refresh. For my footer, I need different button (create
vs save + delete) depending where I am in my flow. I used
ng-swith/ng-switch-when for conditional display in my footer. As
mention earlier I also added jqm-refresh directive so that the button
label changes AND that jqm renders the <a> link as  a button.
But when used before the list is created (angular ng-switch is
resolved), jqm is unhappy an let you know by throwing the classical
exception "cannot call methods on listview prior to initialization"

For that use case I wanted to use priority. I want first to resolve
the ng-switch before the jqm-refresh. Which prioty should I use?

Cheers,
Corinne
> To unsubscribe from this group and stop receiving emails from it, send an email to ang...@googlegroups.com.
Re: [AngularJS] Default priority for custom directive? Corinne Krych 3/1/13 1:16 AM
Hi back

Forgot to precise, if you think it can help I can do a jsFiddle
++
Corinne
Re: [AngularJS] Default priority for custom directive? Dan Kang 3/1/13 10:03 AM
Corinne,

This makes more sense.  It looks like you need to create a watch/event loop within your directive's link function that checks whether ngSwitch has resolved and defer execution until then.

Dan
Re: [AngularJS] Default priority for custom directive? Dan Kang 3/1/13 10:04 AM
Yes, plunker/jsFiddle would allow someone here to help you come up with a more specific workaround!
Re: [AngularJS] Default priority for custom directive? Corinne Krych 3/1/13 2:45 PM
Hi Dan

Here is my jsFiddle
http://jsfiddle.net/corinnekrych/DbHk7/1/

I didn't manage to set the buttonAction to 'ADD' though...

Do you get the idea?
++
COrinne
> --
> 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 ang...@googlegroups.com.

> To post to this group, send email to ang...@googlegroups.com.
> Visit this group at http://groups.google.com/group/angular?hl=en-US.
> For more options, visit https://groups.google.com/groups/opt_out.
>  
>  
Re: [AngularJS] Default priority for custom directive? Dan Kang 3/1/13 3:59 PM
Does this work?

http://jsfiddle.net/DbHk7/3/

On the desktop browser, I don't see any problem with the way this works, but it was refreshing everything fine here without any call to refresh, so it may not work on a mobile browser.  If your problem is that your $watch listener gets fired before the ng-switch watch listener during updates, you can use $timeout to make sure it's executed at least a cycle later.  You may also want to create a custom directive for the entire thing, which may give you more control.  Hope this makes sense!

Dan

> email to angular+u...@googlegroups.com.

> To post to this group, send email to ang...@googlegroups.com.
> Visit this group at http://groups.google.com/group/angular?hl=en-US.
> For more options, visit https://groups.google.com/groups/opt_out.
>  
>  
Re: [AngularJS] Default priority for custom directive? Corinne Krych 3/2/13 4:28 AM
Hello Dan

In fact my problem comes more from the  ng-include directive. My HTML looks like
<section create-refresh="friend" id="section-list-friend" data-role="page">
    <div ng-include src="'js/views/friend-header.html'"></div>
    <div ng-include src="'js/views/friend-list.html'"></div>
    <div ng-include src="'js/views/friend-footer.html'"></div>
</section>

<section id="section-show-friend" data-role="page">
    <div ng-include src="'js/views/friend-header.html'"></div>
    <div ng-include src="'js/views/friend-edit.html'"></div>
    <div ng-include src="'js/views/friend-footer.html'"></div>
</section>

By default jqm renders the first section. My footer contains only a ADD button, clicking on it, I do a jqm: $.mobile.changePage($('#section-list-friend'));
which bring me to the next section in which the footer does not render properly. It renders as a <a> link without jquery mobile enhancement.

I wonder if it's not an issue with jquery mobile though


To unsubscribe from this group and stop receiving emails from it, send an email to ang...@googlegroups.com.

To post to this group, send email to ang...@googlegroups.com.
Visit this group at http://groups.google.com/group/angular?hl=en-US.
For more options, visit https://groups.google.com/groups/opt_out.