Recently, I designed a unique directive that includes various inputs and dropdowns. To ensure proper binding between the outer and inner scopes for two-way data binding, I implemented an isolate scope. This setup allows me to reuse the directive multiple times on a single page without any issues. However, I have now encountered a challenge regarding validation within the directive.
I am unable to rely on the typical approach of using something like:
ng-show="formName.controlname.$invalid && !formname.controlname.$pristine"
This is primarily due to the following reasons:
- The directive should not be concerned with the external form.
- Since I have employed the same directive twice on the page, referencing formName.controlname would point to different controls in each instance.
If you have any suggestions or ideas on how to tackle this issue, I would greatly appreciate your input. What aspect might I be overlooking here?