Use the grid layout to create single and multiple column forms suited for medium and large screens. Don't go overboard with too many columns but make use of the available horizontal space on bigger screens.
Use the global settings for setting the theme, localization options and everything that should be consistent across your app.
While using mobiscroll forms on its own is great and easy there are a lot of cases where a mixed solution is required. There are three common approaches we came across that are covered by this example.
Use mobiscroll form elements inside your existing forms. This is a common scenario that you can come across. Your page is already functional, designed and you would like to update/change a single piece or add something new. Use a stand-alone element like the mbsc-switch in the example.
Use custom styled elements inside mobiscroll forms. Let's say you mostly use mobiscroll on your pages and forms but you also have custom components that you'd like to apply. In that case you want to turn all enahncements off for that element with the the data-enhance="false" property.
Use mobiscroll form elements outside of an actual form. Also a common use case, think of some content like a couple paragraphs and a subscribe call to action in the middle. Use the stand-alone controls, like mbsc-input and mbsc-button elements.
There are two approaches to implement and validate forms in Angular. You can use Mobiscroll forms with both approaches. Mobiscroll takes care of styling and showing the correct message when wired up correctly.
Template driven forms
With template driven validation, we can set up the whole validation in the template of our component using directives as seen in the first part of our example. The #templateForm="ngForm" template variable will hold the FormGroup. We can later check if the form is valid through this variable.
Use required and minlength directives to make the fields required and give the password the minimum 6 charachters long rule. Use the mobiscroll components [error] and [errorMessage] attributes.
To give each error and field a proper error message, set up a message object in the component, and wire them to the proper [errorMessage] attribute.