-
Notifications
You must be signed in to change notification settings - Fork 5
Conversation
@DmitryEfimenko I've created PR to show your POC how #3 can be implemented. I didn't find a way to solve it without structural directive. Also maybe we can do this syntax:
|
I like the idea a lot. Perhaps there's no need for a separate directive. The original <div ngxErrors="zip">
<div ngxError="minlength">Value should be at least 5 long</div>
</div> Below is the syntax for accessing the error object. In addition, we could put the error object into the <div ngxErrors="zip">
<div *ngxError="'minlength'; let err">
Value should be at least {{ err.requiredLength }} long; Right now it's {{ err.actualLength }}
</div>
</div> |
if (!this.ref) { | ||
this.ref = this.viewContainer.createEmbeddedView( | ||
this.template, | ||
this._context |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
{ $implicit: this._context }
to enable syntax I mentioned in the general comments
@DmitryEfimenko do we actually can make regular directive behave as both structural and regular? Can you provide any example? I can' find it The only way I see - make it only structural.
BTW, it seems to me that it should be structural. It works same way as |
You're right. It needs to be a structural directive, which I'm OK with. It's a bigger breaking change, but since we're changing API already, might as well sneak this change in. Besides, the library isn't all that popular yet. This is the time to make it right. |
another option is to actually create a separate structural directive, but promote syntax similar to the following: <div ngxErrors="zip">
<div ngxError="requred">Required</div>
<div ngxError="minlength" *errorData="let err">
Value should be at least {{ err.requiredLength }} long; Right now it's {{ err.actualLength }}
</div>
</div> This way |
PR Checklist
Please check if your PR fulfills the following requirements:
PR Type
What kind of change does this PR introduce?
What is the current behavior?
Issue Number: #3
What is the new behavior?
Does this PR introduce a breaking change?
Other information