Во время проверки с использованием Template Driven Approche возникла ошибка:
Параметр «val» неявно имеет тип «любой», но лучший тип может быть выведен из использования.ts(7044)
здесь я добавляю связанные файлы, пожалуйста, помогите.
<form>
<div class = "form-group">
<label for = "firstName">First Name</label>
<input ngModel name = "firstName" #firstName = "ngModel" (change) = "log(firstName)" id=firstName type = "text" class = "form-control">
</div>
<div class = "form-group">
<label for = "comment">Comments</label>
<textarea id=comment type = "text" cols = "5" rows = "10" class = "form-control"></textarea>
</div>
<div class = "form-group">
<button class = "btn btn-danger">Submit</button>
</div>
</form>
компонент.ts
import { Component, OnInit } from '@angular/core';
@Component({
selector: 'contact-form',
templateUrl: './contact-form.component.html',
styleUrls: ['./contact-form.component.scss']
})
export class ContactFormComponent {
log(val)
{
console.info(val);
}
}
tsconfig.json
/* To learn more about this file see: https://angular.io/config/tsconfig. */
{
"compileOnSave": false,
"compilerOptions": {
"baseUrl": "./",
"outDir": "./dist/out-tsc",
"forceConsistentCasingInFileNames": true,
"strict": true,
"noImplicitReturns": true,
"noFallthroughCasesInSwitch": true,
"sourceMap": true,
"declaration": false,
"downlevelIteration": true,
"experimentalDecorators": true,
"moduleResolution": "node",
"importHelpers": true,
"target": "es2015",
"module": "es2020",
"lib": [
"es2018",
"dom"
],
"noImplicitAny": false
},
"angularCompilerOptions": {
"strictInjectionParameters": true,
"strictInputAccessModifiers": true,
"strictTemplates": true
}
}
@PanagiwthsMpougioukos - (параметр) val: любой . когда я нажимаю Ctrl+. он был изменен на log(val: any)
какую версию машинописного текста вы используете?
@PanagiwthsMpougioukos "версия": "4.0.5"
Добавлен FormsModule в app.module.ts при импорте
imports: [
BrowserModule,
AppRoutingModule,
FormsModule -- Added Here
],
будет решен вопрос для меня
Также нашел ошибку в консоли как Ошибка: Экспорт имени «ngModel» не найден
Какой тип выводится в коде Visual Studio при наведении курсора на этот параметр?