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.
It would allow for improvement in modern editors, like Webstorm, to parse a directive and list supported attribute values.
It would allow Angular to parse such attributes when encountering the containing directive and produce a meaningful error when needed, as opposed to letting each directive deal with it. In fact, Angular would even be able to parse the attribute value dynamically when it is used through a model as opposed to static string.
With the right approach enum-s could be extended to contain both value, and id and a text description, like a self-documenting look-up dictionary. This would be awesome.
Example.
app.directive('food', [function () {
return {
scope: {
type: [
{
$id: 1,
$value: 'fruit',
$doc: 'bla-bla'
},
{
$id: 2,
$value: 'vegetable',
$doc: 'bla-bla'
}]
},
restrict: 'E',
link: function (scope) {
/* automatically extending scope.type with: $id, $value, $doc, $index */
switch (scope.type.$value) {
case 'fruit':
break;
case 'vegetable':
break;
default:
/* Will never get here because Angular won't let it */
break;
}
}
}
}]);
The text was updated successfully, but these errors were encountered:
Yeh, but what you are really asking for here is a regular type system... It would be interesting to see how much millage we can get from adopting types (AtScript, TypeScript or similar) for this use-case...
Example.
The text was updated successfully, but these errors were encountered: