New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

ng-form-decorators

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ng-form-decorators

First the definitions in the tsconfig.json file must be updated:

  • 1.2.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
2
increased by100%
Maintainers
1
Weekly downloads
 
Created
Source

A utility to assist in creating Angular forms through Classes using TypeScript annotations.

First the definitions in the tsconfig.json file must be updated:

{
    "compilerOptions":{
		...
		"emitDecoratorMetadata": true,
	    "experimentalDecorators": true
	}
    
}

Obs: The model must be initialized with default values to perform the mapping and build the JavaScript models.

Now we can define a template, and use the annotations available for form configuration:

import { NgFormValidators } from 'ng-form-decorators';
class User {
	name: string = '';
	@NgFormValidators([Validators.required, Validators.max(45)])
	idade: number = null;
}

Use NgFormGroup to define a FormGroup as an attribute of another FormGroup through the building model.

import { NgFormValidators, NgFormGroup } from 'ng-form-decorators';
class  Home {
	@NgFormValidators([Validators.required])
	number:  number  =  null;
	street:  string  =  null;
	@NgFormGroup()
	user:  User;
}

At the end of the definitions, define a variable in the component to represent FormGroup and annotate it with NgFormModel defining the authoring template, and then a form will be built and injected into the variable.

import { NgFormModel } from 'ng-form-decorators';
import { Home } from './models/home.model.ts';
export  class  AppComponent  {

	@NgFormModel(Home)
	formHome:  FormGroup;
}

FAQs

Package last updated on 04 Nov 2019

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc