'Error: NG0301: Export of name 'ngModel' not found
So I'm trying to add a simple validation message.
App.Module.ts
import { FormsModule, ReactiveFormsModule } from '@angular/forms';
@NgModule({
...
imports: [ FormsModule, ReactiveFormsModule, ]
})
HTML
<div class="form-group">
<label>Nickname</label>
<input type="text" class="form-control"
id="nickname" formControlName="nickname"
[(ngModel)]="MyProfileForm.nickname" name="nickname" #nickname="ngModel">
<div [hidden]="nickname.valid" class="alert alert-danger">Nickname is required.</div>
</div>
.ts
import { FormBuilder, FormControl, FormGroup, Validators, FormsModule, NgModel } from "@angular/forms";
export class MyProfileComponent
{
constructor(private fbdr: FormBuilder) { }
People = ...;
MyProfileForm: FormGroup;
this.MyProfileForm = this.fbdr.group
(
{
nickname: new FormControl(this.People.selfnickname, [Validators.required, Validators.minLength(4)])
}
);
}
I've tried all answers of this SO.
Full stack from console:
core.js:6210 ERROR Error: Uncaught (in promise): Error: NG0301: Export of name 'ngModel' not found!. Find more at https://angular.io/errors/NG0301 Error: NG0301: Export of name 'ngModel' not found!. Find more at https://angular.io/errors/NG0301 at cacheMatchingLocalNames (core.js:10393) at resolveDirectives (core.js:10224) at elementStartFirstCreatePass (core.js:14786) at ɵɵelementStart (core.js:14823) at MyProfileComponent_Template (template.html:21) at executeTemplate (core.js:9614) at renderView (core.js:9418) at renderComponent (core.js:10698) at renderChildComponents (core.js:9283) at renderView (core.js:9443) at resolvePromise (zone.js:1209) at resolvePromise (zone.js:1163) at zone.js:1275 at ZoneDelegate.invokeTask (zone.js:402) at Object.onInvokeTask (core.js:28578) at ZoneDelegate.invokeTask (zone.js:401) at Zone.runTask (zone.js:174) at drainMicroTaskQueue (zone.js:578) at ZoneTask.invokeTask [as invoke] (zone.js:487) at invokeTask (zone.js:1596)
Solution 1:[1]
It is probably because of the difference in data sets. MNIST numbers usually has more solid colors and bolder than your own numbers. That is the only thing come up to my mind, because your code looks fine.
The solution is to change your numbers as more similar to MNIST numbers or creating a large enough data set with your numbers to train the model with them.
Solution 2:[2]
You are using following line of code while processing the images after loading them:
pic = 255 - pic
This preprocessing step is not present in the training step. Maybe this is the reason why most images are incorrectly classified.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Baran |
| Solution 2 | Ravindra Sonawane |
