0

I'm developing a small AngularJS (1.6) app, trying to use a component-based architecture.

enter image description here

On my HomePageComponent, I have three different sub-component A, B and C, which all contains different content such as input fields, datepickers and a list. It should not be possible to navigate to the next page (state) if a validation in any of my sub-components fails. The "Button A" should therefore be disabled - ex. name input field in component A is not set.

However, I can't seem to find a reasonable solution/pattern on how to achieve this functionality while using components.

Does anyone have a proper solution for this? Thanks in advance

1
  • 1
    In the HomePageComponent if you add a <form> any inputs and validation in your nested components will participate in the outer form validation Commented Jun 28, 2017 at 4:58

1 Answer 1

1

You could consider using a wizard such as angular-wizard . From the github page:

<wizard on-finish="finishedWizard()" on-cancel="cancelledWizard()"> 
    <wz-step wz-title="Starting">
        <h1>This is the first step</h1>
        <p>Here you can use whatever you want. You can use other directives, binding, etc.</p>
        <input type="submit" wz-next value="Continue" />
    </wz-step>
    <wz-step wz-title="Continuing">
        <h1>Continuing</h1>
        <p>You have continued here!</p>
        <input type="submit" wz-next value="Go on" />
    </wz-step>
    <wz-step wz-title="More steps">
        <p>Even more steps!!</p>
        <input type="submit" wz-next value="Finish now" />
    </wz-step>
</wizard>
Sign up to request clarification or add additional context in comments.

1 Comment

Thanks - I'll look in to it.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.