You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Apr 12, 2024. It is now read-only.
In my Directives I would love to be able to specify that value coming from an attribute is of type boolean or number or perhaps even Date. Ideally I see it as an enhancement to your syntax where when you set scope hash you can also specify the type. For example:
scope: {myNumber: '#@',//Where # would attempt to cast value to NumbermyBoolean: '!@',//Where ! would attempt to cast value to Boolean}
Rational for this is that very often I end up doing something like $scope.myValue === 'true' instead of just testing for its intended type.
The text was updated successfully, but these errors were encountered:
Interesting. Somehow related, I often have boilerplate in observers that need to cast stuff to boolean. Wiht scope bindings I find it less useful, or better: I find it out of scope fo angular to include a type system.
For two way binding ('=') there is no need to cast since the scope variable will always be with the same type as the bound variable. This is only relevant for interpolated ('@') scope variables, which are always of string type. Or am I missing something?
You're right I made a mistake, it should have been for one-way bound values '@' not '='. Apologies!
It is in fact to tackle values that always come as strings.
Corrected example.
Sign up for freeto subscribe to this conversation on GitHub.
Already have an account?
Sign in.
In my Directives I would love to be able to specify that value coming from an attribute is of type boolean or number or perhaps even Date. Ideally I see it as an enhancement to your syntax where when you set scope hash you can also specify the type. For example:
Rational for this is that very often I end up doing something like $scope.myValue === 'true' instead of just testing for its intended type.
The text was updated successfully, but these errors were encountered: