Marcelle  Smith

Marcelle Smith


Angular Model Driven Forms

Model driven forms is a new concept in angular 2. In angular 1, all we had was template driven forms which by the way, you can still use in Angular 2.

What is a model driven form?

Before we look at why you would want to use model driven forms, what do we mean by model driven forms?


Architecturally, a form has 4 parts:

  • DOM. This is where the form is rendered to!
  • Template. This defines how the fields are laid out in the DOM
  • Form Model. This defines the fields on the form and some of the associated UI logic such as what the client side validation rules are and what the default values are
  • Domain Model. This contains the fields and their values

In angular 1, the form model was hidden from us - angular creates this for us from the template. In angular 2 we can create the form model using FormBuilder. Using FormBuilder in Angular 2 is taking the model driven approach.

#angular #typescript

What is GEEK

Buddha Community

Angular Model Driven Forms
Christa  Stehr

Christa Stehr


Install Angular - Angular Environment Setup Process

Angular is a TypeScript based framework that works in synchronization with HTML, CSS, and JavaScript. To work with angular, domain knowledge of these 3 is required.

  1. Installing Node.js and npm
  2. Installing Angular CLI
  3. Creating workspace
  4. Deploying your First App

In this article, you will get to know about the Angular Environment setup process. After reading this article, you will be able to install, setup, create, and launch your own application in Angular. So let’s start!!!

Angular environment setup

Install Angular in Easy Steps

For Installing Angular on your Machine, there are 2 prerequisites:

  • Node.js
  • npm Package Manager

First you need to have Node.js installed as Angular require current, active LTS or maintenance LTS version of Node.js

Download and Install Node.js version suitable for your machine’s operating system.

Npm Package Manager

Angular, Angular CLI and Angular applications are dependent on npm packages. By installing Node.js, you have automatically installed the npm Package manager which will be the base for installing angular in your system. To check the presence of npm client and Angular version check of npm client, run this command:

  1. npm -v

Installing Angular CLI

  • Open Terminal/Command Prompt
  • To install Angular CLI, run the below command:
  1. npm install -g @angular/cli

installing angular CLI

· After executing the command, Angular CLI will get installed within some time. You can check it using the following command

  1. ng --version

Workspace Creation

Now as your Angular CLI is installed, you need to create a workspace to work upon your application. Methods for it are:

  • Using CLI
  • Using Visual Studio Code
1. Using CLI

To create a workspace:

  • Navigate to the desired directory where you want to create your workspace using cd command in the Terminal/Command prompt
  • Then in the directory write this command on your terminal and provide the name of the app which you want to create. In my case I have mentioned DataFlair:
  1. Ng new YourAppName

create angular workspace

  • After running this command, it will prompt you to select from various options about the CSS and other functionalities.

angular CSS options

  • To leave everything to default, simply press the Enter or the Return key.

angular setup

#angular tutorials #angular cli install #angular environment setup #angular version check #download angular #install angular #install angular cli

Turner  Crona

Turner Crona


Angular simple dynamic template-driven form for beginners

Template driven forms are model driven forms driven by directives in a template. Template driven forms are approached by angular JS users but sometimes template driven forms will be used for complex systems. For instance, if you want to dynamically set to validate a particular form filed you can use template driven forms. In the template driven forms uses two way data binding in terms of it uses ngModel despite formControl and fromGroups.

Form structure

I am going to create a simple form that is able to create new form fields. The number of form-fields depends on the user. It can be changed at run time.

However, each form entry requires a name like formControlName in reactive forms and the state of the form as a whole that is a collection of individual form fields. Each form filed is assigned a unique id property. Therefore, template driven form controls need to be uniquely named. We can generate form fields using a unique control name. In this dynamic form, it has been used the current timestamp as a unique id or you can create a method to get random numbers to assign for this unique id. So it can get through with parent NgForm.

First, import formsModule to main module ex:- app.module.ts then create an interface to describe an object. You have to set some properties you want to this interface.

<form #parentForm="ngForm" (submit)="submitParentForm(parentForm)">
	    <ng-template ngFor let-form [ngForOf]="mainForm.formFields" let-index="index" let-isLast="last">
	            name="formFirld1_{{ }}"
	        <div *ngIf="parentForm.submitted && !form.formField1.value">Form field 1 is required</div>
	            name="formFirld2_{{ }}"
	         <div *ngIf="parentForm.submitted && !form.formField2.value">Form field 2 is required</div>
	        <button (click)="removeForm(index)">Remove form</button>
	    <button type="submit">Submit</button>
	    <button type="button" (click)="parentForm.reset()">
	<button (click)="addForm()" [disabled]="(!parentForm.form.valid)">Add new form</button>

#dynamic-form #angular-for-beginners #template-driven-form #angular

Angular Form Generator & Pitfalls

Ever felt repetitive creating forms in your Angular Application? Let’s fix it.


During the Front-end development days it feels like there is a lot of repetitive code which I have to write to design my forms which are almost all the time very close one to another.

I’ve been recently looking into ways of automating it. The furthest I wanted to go was to have some kind of interface between a more friendly modelling object as well as to an interface to link my objects to the Angular Modelling Universe.

This way, I discovered there is already a library that could do it for me formly. But looking over their documentation I realized this is a little bit more than I wanted.

As a result, I ended writing my own form generator. You’ll see that except for two or three pitfalls this is rather easy to achieve.


I’ll be using Angular Materials to generate my forms.

I have two tips to share about their design. It can be difficult to change the colors or design a theme for them. You’ll see the documentation on their side is rather not the best on this subject. My piece of advice, use In case you don’t know exactly what colors to use but you have a slight idea about it, I recommend using In the end you’ll definitely discover some very cool Angular Material Theme which you can even share with others.

Getting Started

First of all, we’ll organize our application on modules. When it comes to Angular I always split the code in presentation and business. From where I’m standing, presentation means those components that deal with UX functionality, they can work by themselves but they don’t make sense for a user taken alone; business are those components that configure and group together presentation through a context.

#angular-forms #angular #typescript #angular-formly

Roberta  Ward

Roberta Ward


Basics of Angular: Part-1

What is Angular? What it does? How we implement it in a project? So, here are some basics of angular to let you learn more about angular.

Angular is a Typescript-based open-source front-end web application platform. The Angular Team at Google and a community of individuals and corporations lead it. Angular lets you extend HTML’s syntax to express your apps’ components clearly. The angular resolves challenges while developing a single page and cross-platform applications. So, here the meaning of the single-page applications in angular is that the index.html file serves the app. And, the index.html file links other files to it.

We build angular applications with basic concepts which are NgModules. It provides a compilation context for components. At the beginning of an angular project, the command-line interface provides a built-in component which is the root component. But, NgModule can add a number of additional components. These can be created through a template or loaded from a router. This is what a compilation context about.

What is a Component in Angular?

Components are key features in Angular. It controls a patch of the screen called a view. A couple of components that we create on our own helps to build a whole application. In the end, the root component or the app component holds our entire application. The component has its business logic that it does to support the view inside the class. The class interacts with the view through an API of properties and methods. All the components added by us in the application are not linked to the index.html. But, they link to the app.component.html through the selectors. A component can be a component and not only a typescript class by adding a decorator @Component. Then, for further access, a class can import it. The decorator contains some metadata like selector, template, and style. Here’s an example of how a component decorator looks like:

    selector: 'app-root',
    templateUrl: 'app.component.html',
    styleUrls: ['app.component.scss']

Role of App Module

Modules are the package of functionalities of our app. It gives Angular the information about which features does my app has and what feature it uses. It is an empty Typescript class, but we transform it by adding a decorator @NgModule. So, we have four properties that we set up on the object pass to @NgModule. The four properties are declarations, imports, providers, and bootstrap. All the built-in new components add up to the declarations array in @NgModule.

declarations: [
imports: [
bootstrap: [AppComponent]

What is Data Binding?

Data Binding is the communication between the Typescript code of the component and the template. So, we have different kinds of data binding given below:

  • When there is a requirement to output data from our Typescript code in the HTML template. String interpolation handles this purpose like {{data}} in HTML file. Property Binding is also used for this purpose like [property] = “data”.
  • When we want to trigger any event like clicking a button. Event Binding works while we react to user events like (event) = “expression”.
  • When we can react to user events and output something at the same time. Two-way Binding is used like [(ngModel)] = “data”.

image for understanding data binding

#angular #javascript #tech blogs #user interface (ui) #angular #angular fundamentals #angular tutorial #basics of angular

I am Developer


Angular 11 Reactive Forms Validation Tutorial

Reactive form validation in Angular 11 app. In this tutorial, i will show you how to use reactive form validation in angular 11 app.

As well as, and you will learn how use reactive form validation in angular 11. And also use reactive form with formGroup for validation in angular 11 app.

Reactive Form Validation In Angular 11
Step 1 – Create New Angular App
Step 2 – Import Form Module
Step 3 – Add Code on View File
Step 4 – Use Component ts File
Step 5 – Start Angular App

#reactive form validation in angular 11 #angular 11/10/9/8/7 reactive forms validation example #angular 11 form validation example