Closed
Description
Versions
ng --version
Angular CLI: 1.6.2
Node: 9.3.0
OS: win32 x64
Angular: 5.1.2
... animations, common, compiler, compiler-cli, core, forms
... http, language-service, platform-browser
... platform-browser-dynamic, router
@angular/cli: 1.6.2
@angular-devkit/build-optimizer: 0.0.36
@angular-devkit/core: 0.0.22
@angular-devkit/schematics: 0.0.42
@ngtools/json-schema: 1.1.0
@ngtools/webpack: 1.9.2
@schematics/angular: 0.1.11
@schematics/schematics: 0.0.11
typescript: 2.4.2
webpack: 3.10.0
Repro steps
- Step 1
ng new testProject - Step 2
cd testProject - Step 3
npm install - Step 4
add code in /src/app/app.component.html:
<li>
<h2><a target="_blank" rel="noopener" href="https://blog.angular.io/">Angular blog</a></h2>
</li>
<!--my code begin-->
<li>
<div>
<label>field</label>
<input [(ngModel)]="model.field" #field="ngModel"/>
</div>
</li>
<li>
<div>untouched - {{field.untouched}} </div>
<div>pristine - {{field.pristine}} </div>
</li>
<!--my code end-->
- Step 5
add code in /src/app/app.component.ts:
export class AppComponent {
title = 'app';
// my code begin
model = {
field: ''
};
// my code end
}
- Step 6
add code in /src/app/app.module.ts:
import { FormsModule, ReactiveFormsModule } from '@angular/forms';
...
imports: [
BrowserModule,
FormsModule,
ReactiveFormsModule
],
- Step 7
npm run build