Skip to content

Commit

Permalink
Merge pull request #75 from Nkzlxs/patch-1
Browse files Browse the repository at this point in the history
Fix markdown typo in README for no.256 and 258
  • Loading branch information
sudheerj authored Apr 3, 2023
2 parents 9dca487 + ffcb8dc commit 51310b7
Showing 1 changed file with 38 additions and 40 deletions.
78 changes: 38 additions & 40 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4148,24 +4148,24 @@
</label>
```
Finally, the component with reactive form control appears as below,
```js
import { Component } from '@angular/core';
import { FormControl } from '@angular/forms';
@Component({
selector: 'user-profile',
styleUrls: ['./user-profile.component.css']
template: `
<label>
User name:
<input type="text" [formControl]="userName">
</label>
`
})
export class UserProfileComponent {
userName = new FormControl('');
}
```
```js
import { Component } from '@angular/core';
import { FormControl } from '@angular/forms';
@Component({
selector: 'user-profile',
styleUrls: ['./user-profile.component.css'],
template: `
<label>
User name:
<input type="text" [formControl]="userName">
</label>
`
})
export class UserProfileComponent {
userName = new FormControl('');
}
```
**[⬆ Back to Top](#table-of-contents)**
Expand Down Expand Up @@ -4200,8 +4200,8 @@
2. Bind the form from template to the component using ngModel syntax
```html
<input type="text" class="form-control" id="name"
required
[(ngModel)]="model.name" name="name">
required
[(ngModel)]="model.name" name="name">
```
3. Attach NgForm directive to the <form> tag in order to create FormControl instances and register them
```js
Expand All @@ -4225,28 +4225,26 @@
// Form goes here
<button type="submit" class="btn btn-success" [disabled]="!registerForm.form.valid">Submit</button>
```
Finally, the completed template-driven registration form will be appeared as follow.
```html
<div class="container">
<h1>Registration Form</h1>
<form (ngSubmit)="onSubmit()" #registerForm="ngForm">
<div class="form-group">
<label for="name">Name</label>
<input type="text" class="form-control" id="name"
required
[(ngModel)]="model.name" name="name"
#name="ngModel">
<div [hidden]="name.valid || name.pristine"
class="alert alert-danger">
Please enter your name
</div>
</div>
<button type="submit" class="btn btn-success" [disabled]="!registerForm.form.valid">Submit</button>
</form>
```html
<div class="container">
<h1>Registration Form</h1>
<form (ngSubmit)="onSubmit()" #registerForm="ngForm">
<div class="form-group">
<label for="name">Name</label>
<input type="text" class="form-control" id="name"
required
[(ngModel)]="model.name" name="name"
#name="ngModel">
<div [hidden]="name.valid || name.pristine"
class="alert alert-danger">
Please enter your name
</div>
</div>
```
<button type="submit" class="btn btn-success" [disabled]="!registerForm.form.valid">Submit</button>
</form>
</div>
```
**[⬆ Back to Top](#table-of-contents)**
Expand Down

0 comments on commit 51310b7

Please sign in to comment.