angular required field

Form validation tricks in Angular 1.x

AngularJS it’s a JavaScript-framework with open source. It’s exploit to develop single-page applications. Its aim is to splay browser-based apps based on the MVC template and simplify testing and development.

The template works with HTML that contains additional custom attributes that are described by the directives and links the input or output of the page region to a model that is a regular JavaScript variable. The values ​​of these variables are set manually or extracted from static or dynamic JSON data.

The components of Angular 1.5 have made the selection of the default region, and this is correct. But it means that intercomponent communication requires more attention.

The angular mechanism requires the efficient exchange of certain forms of components, especially through a set of related components.

The mechanism of exactingness is hoary, and it is used quite a lot for the expanded connection with the angular control.

Before components, you have to exploit a query to permit direct admission to the controller of another directive. This gives directives an opportunity to augment the API to each other.

A directive may need the subsistence of another specific directive. It can be on its own element or on one of its parent elements.

Typically, a sample of this type of connection is used, which adds the validation directive to the input element and accesses the ngModelController of this entry to modify the validators.

Each entry in the form can notify the form that is valid, invalid, dirty, etc., optionally requiring the ngForm parent controller and updating its changes.

It requires a very powerful mechanism and an integral part of the Angular, which you can exploit to make components cleaner.

The requirement doesn’t work in all scenarios. It can only be exploit by the component/directive to access the parent controller or controller on the same element. Sibling components can’t communicate with it, and none of the parent components can use children ones. Another limitation of the requirement is that it suggests that the child component is acquainted with the name of the other component that it wants to require.

Also, you don’t need to exploit it to replace any simple binding. It is perfectly accurate to transfer some values ​​between components using bindings – it can be expressive and simpler to support. It’s usually easier to realize what’s dependent on the component, if all you have to perform is to observe its bindings.

Require shines in case it permits you to configure a family of interacting components and expose the rich interface between them, without connecting up to half a dozen bindings to several layers of components.

Igor Grigorenko

Add comment

Subscribe