Coder Social home page Coder Social logo

anhvupt / angular-custom-input-field Goto Github PK

View Code? Open in Web Editor NEW
1.0 1.0 0.0 262 KB

Custom form control using the ControlValueAccessor interface, implemented as a component with an attribute selector.

Home Page: https://stackblitz.com/edit/angular-d2fu8a

HTML 45.96% TypeScript 49.14% SCSS 2.99% JavaScript 1.91%
angular standalone-components

angular-custom-input-field's Introduction

angular-custom-input-field

Edit on StackBlitz ⚡️

This is a simple Angular application that demonstrates how to create a custom form control using the ControlValueAccessor interface. The custom form control is implemented as a component called FormFieldComponent, which is used to create a text input field that can be used in Angular forms.

Installation

To install and run the application, follow these steps:

  1. Clone or download the project from GitHub.

  2. Open the project folder in your preferred code editor.

  3. Install the required dependencies by running the following command in the terminal:

npm install

  1. Start the development server by running the following command in the terminal:

ng serve

  1. Open your web browser and navigate to http://localhost:4200 to view the application.

Usage

The FormFieldComponent component can be used as a custom form control in Angular forms. To use the component, import it into your Angular module and add it to your form's template.

Here's an example of how to use the FormFieldComponent component in an Angular form:

<form [formGroup]="myForm" (submit)="onSubmit()">
<section app-form-field formControlName="firstName" label="First Name"></section>
<section app-form-field formControlName="lastName" label="Last Name"></section>
<section app-form-field type="submit">Submit</section>
</form>

In this example, the app-form-field component is used to create two text input fields for the user's first name and last name. The formControlName attribute is used to bind the form controls to the corresponding fields in the form's FormGroup object.

Contributing If you find a bug or would like to suggest a new feature, please open an issue or submit a pull request on GitHub.

License This project is licensed under the MIT License. See the LICENSE file for more information.

angular-custom-input-field's People

Contributors

anhvupt avatar

Stargazers

 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.