What are the practical differences between template-driven and reactive forms?

I have been reading about Angular2 new Forms API and it seems that there are two approaches on forms, one is Template driven forms other is reactive or model-driven forms. I would like to know the practical difference between the two, not the difference in syntax (obviously) but practical uses and which approach benefits more … Read more

TypeScript-‘s Angular Framework Error – “There is no directive with exportAs set to ngForm”

I keep getting this error while using TypeScript’s Angular2-forms framework: There is no directive with “exportAs” set to “ngForm” Here’s my code project dependencies : “dependencies”: { “@angular/common”: “2.0.0-rc.6”, “@angular/compiler”: “2.0.0-rc.6”, “@angular/core”: “2.0.0-rc.6”, “@angular/forms”: “2.0.0-rc.6”, “@angular/http”: “2.0.0-rc.6”, “@angular/platform-browser”: “2.0.0-rc.6”, “@angular/platform-browser-dynamic”: “2.0.0-rc.6”, “@angular/router”: “3.0.0-rc.2”, “ng2-bootstrap”: “^1.1.1”, “reflect-metadata”: “^0.1.8”, “core-js”: “^2.4.0”, “es6-module-loader”: “^0.17.8”, “rxjs”: “5.0.0-beta.11”, “systemjs”: “0.19.27”, … Read more

tslint / codelyzer / ng lint error: “for (… in …) statements must be filtered with an if statement”

Lint error message: src/app/detail/edit/edit.component.ts[111, 5]: for (… in …) statements must be filtered with an if statement Code snippet (It is a working code. It is also available at angular.io form validation section): for (const field in this.formErrors) { // clear previous error message (if any) this.formErrors[field] = ”; const control = form.get(field); if (control … Read more

How can I manually set an Angular form field as invalid?

I am working on a login form and if the user enters invalid credentials we want to mark both the email and password fields as invalid and display a message that says the login failed. How do I go about setting these fields to be invalid from an observable callback? Template: <form #loginForm=”ngForm” (ngSubmit)=”login(loginForm)” id=”loginForm”> … Read more

Can’t bind to ‘formGroup’ since it isn’t a known property of ‘form’

The situation I am trying to make what should be a very simple form in my Angular application, but no matter what, it never works. The Angular version Angular 2.0.0 RC5 The error Can’t bind to ‘formGroup’ since it isn’t a known property of ‘form’ The code The view <form [formGroup]=”newTaskForm” (submit)=”createNewTask()”> <div class=”form-group”> <label … Read more