[Ionic] Common error

1. Cannot bind a value to NgModel in component

Issue: cannot set value to [(ngModel)]=”startDate” in any Component

Reason: lack of import  IonicModule, FormsModule in ComponentModule

Solution:

// in your-component.modules.ts file
imports: [
    ......
    IonicModule,
    FormsModule       
  ]

2. ERROR Error: Uncaught (in promise): Error: JIT compiler unavailable Error: JIT compiler unavailable

Điều này xảy ra khi trong component của bạn có sử dụng @ViewChild.

export class UserprofilePage implements OnInit {
	@ViewChild(MemberdetailsComponent) memberDetails: MemberdetailsComponent; // Sử dụng view child ở đây
	@ViewChild(MemberNomineeDetailComponent)
	nominees: MemberNomineeDetailComponent;

Nguyên nhân:

https://github.com/angular/angular/issues/37244

Cách fix: go to tsconfig.json

"angularCompilerOptions": {
    "enableI18nLegacyMessageIdFormat": false,
    "strictInjectionParameters": true,
    "strictInputAccessModifiers": true,
    "strictTemplates": true,
    "compileNonExportedClasses": false // <-- Thêm dòng này vào 
  }

F G+ T

tuandph

Khởi đầu với .NET từ năm 2013 đến nay. Hiện tại mình đang làm full-stack developer. Yêu thích lập trình & chia sẽ kiến thức. Thời gian rảnh thường làm những tool vui vui và viết lách kể lệ sự đời.