Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Few questions about directives
Message
From
26/02/2015 03:53:20
 
General information
Forum:
Javascript
Category:
Other
Miscellaneous
Thread ID:
01615790
Message ID:
01615852
Views:
51
This message has been marked as a message which has helped to the initial question of the thread.
>>But you really want your formatter to run *after* the angular formatter (so it can strip the commas that are present) and, since it will get it's value as a string it would need to be rewritten accordingly.
>>
>>UPDATE: I see it is expecting a string so forget the last bit.
>>
>>What I'm not sure about is how you ensure your formatter is second in the chain.....
>>
>>UPDATE2 : Duh. I now see that's what you were trying with negative priority. Did you check the actual order obtained in that case ?
>
>I am not exactly sure how to test. I could not find priority property anywhere.
>
>When I was debugging, I think I saw the formatter running first and then the InputNumber code, but I am getting confused.

My logic is this:

$formatters is an array of functions which are pipelined in reverse order.
You want angulars numberInputType formatter to run first, followed by your own smNumberFormat.
The two directives push their formatting methods into the array.
The order in which they are pushed depends on the priority order of the directive (higher numbers are compiled first)
The angular priority is 0.
So giving your directive priority *greater* than 0 should put your formatter first in the array and angulars second.
Since they are pipelined in reverse order that should give you the desired behaviour.

So you want a priority > 0 for smNumberFormat

UPDATE: Again I could be wrong. angular docs state the directives with a higher priority are compiled first but post-link functions are run in reverse order and I'm not sure what applies in this case. Maybe your directive *should* have a negative number.

IAC, one or the other should work :-}
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform