错误 TS2339:“HTMLElement”类型上不存在属性“name”

巴拉德瓦·耶拉普拉加达

profile.component.ts:

var $inputs = $('#changePasswordForm :input');
    var values = {
      oldpassword: String,
      newpassword: String
    };
    $inputs.each(function() {
      console.log(this);
      values[this.name] = $(this).val();
    });
    console.log(values.oldpassword, this.currentUser.username);

profile.component.html:

<form id='changePasswordForm'>
            <div class='form-group input-field'>
              <label for=''>Old Password*</label>
              <input type='password' [(ngModel)]='oldpassword' name='oldpassword' class='form-control'>
            </div>
            <div class='form-group input-field'>
              <label for=''>New Password*</label>
              <input type='password' [(ngModel)]='newpassword' name='newpassword' class='form-control'>
            </div>
          </form>

错误:

src/app/components/profile/profile.component.ts(82,19) 中的错误:错误 TS2339:“HTMLElement”类型上不存在属性“name”。

我做错了什么??

幻影

尽量不要在 Angular 中使用 JQuery

您可以在 Angular(ngx) 中执行这样的代码。您使用的ngModel是双向绑定,您可以在组件文件中访问此值。

HTML

<form id='changePasswordForm' (ngSubmit)="changePass()">
            <div class='form-group input-field'>
              <label for=''>Old Password*</label>
              <input type='password' [(ngModel)]='oldpassword' name='oldpassword' class='form-control'>
            </div>
            <div class='form-group input-field'>
              <label for=''>New Password*</label>
              <input type='password' [(ngModel)]='newpassword' name='newpassword' class='form-control'>
            </div>

            <button type="submit">Change Password</button>
</form>

TS(组件)

import { Component } from '@angular/core';

@Component({
  selector: 'my-app',
  templateUrl: './app.component.html',
  styleUrls: [ './app.component.css' ]
})
export class AppComponent  {

  oldpassword: string;
  newpassword: string;

  changePass() {

// Here we are getting and setting values
    const values = {
        oldpassword: this.oldpassword,
        newpassword: this.newpassword
    };

    console.log(values);
  }
}

https://stackblitz.com/edit/ngx-change-password-demo

本文收集自互联网,转载请注明来源。

如有侵权,请联系[email protected] 删除。

编辑于
0

我来说两句

0条评论
登录后参与评论

相关文章

来自分类Dev

如何解决错误“TS2339:'JQuery<HTMLElement>' 类型上不存在属性 'gauge'。”

来自分类Dev

错误:'错误 TS2339:'Response' 类型上不存在属性 'data'。- Angular

来自分类Dev

错误TS2339:类型“响应”上不存在属性“结果”

来自分类Dev

错误TS2339:类型“ Y”上不存在属性“ x”

来自分类Dev

打字稿错误TS2339:类型“ {}”上不存在属性“项目”

来自分类Dev

错误TS2339:类型“字符串”上不存在属性“ endsWith”

来自分类Dev

如何修复错误TS2339:类型上不存在属性“ authToken”

来自分类Dev

Express.js / Typescript:错误TS2339:类型“ Response”上不存在属性“ send”

来自分类Dev

错误TS2339:类型“订阅”上不存在属性“订阅”

来自分类Dev

角度:错误TS2339:类型“对象”上不存在属性“数据”

来自分类Dev

角度:错误TS2339:类型“对象”上不存在属性“数据”

来自分类Dev

错误TS2339:类型“ AngularFireAuth”上不存在属性“ auth”

来自分类Dev

TypeScript错误TS2339:类型“ EventTarget”上不存在属性“ matches”

来自分类Dev

错误TS2339:类型'PromiseLike <void>'上不存在属性'catch'

来自分类Dev

错误 TS2339:类型“Angular2”上不存在属性“”

来自分类Dev

错误 TS2339:类型“{}”上不存在属性“includes”

来自分类Dev

错误 TS2339:“FormData”类型上不存在属性“entries”

来自分类Dev

错误 TS2339:“导航器”类型上不存在“相机”属性

来自分类Dev

错误 TS2339:类型“y[] 上不存在属性“x”

来自分类Dev

错误 TS:2339 类型 {} 上不存在属性“项目”

来自分类Dev

angular2:错误:(62,33)TS2339:类型'typeof Injector'上不存在属性'resolveAndCreate'

来自分类Dev

打字稿| Array.from | 错误TS2339:类型“ ArrayConstructor”上不存在属性“来自”

来自分类Dev

错误 TS2339:“对象”类型上不存在属性“JSON”。".map(resp => resp.JSON())" 角度 4

来自分类Dev

如何解决 TypeScript 编译器错误 TS2339:我的 Angular 5 应用程序中的类型 {} 上不存在属性“errorValue”

来自分类Dev

错误TS2339:类型'{新():控制台上不存在属性'log';原型:控制台;}'

来自分类Dev

错误显示在我的 .ts 代码中 > [ts] 类型“any[]”上不存在属性“name”

来自分类Dev

TS2339:类型“{}”上不存在属性“props”

来自分类Dev

使用Typescript类型错误反应“自定义挂钩”“类型'interface |(({{target}:any)=> void)'。ts(2339)上不存在属性'x'

来自分类常见问题

useRef Typescript错误:类型“ HTMLElement”上不存在属性“当前”

Related 相关文章

  1. 1

    如何解决错误“TS2339:'JQuery<HTMLElement>' 类型上不存在属性 'gauge'。”

  2. 2

    错误:'错误 TS2339:'Response' 类型上不存在属性 'data'。- Angular

  3. 3

    错误TS2339:类型“响应”上不存在属性“结果”

  4. 4

    错误TS2339:类型“ Y”上不存在属性“ x”

  5. 5

    打字稿错误TS2339:类型“ {}”上不存在属性“项目”

  6. 6

    错误TS2339:类型“字符串”上不存在属性“ endsWith”

  7. 7

    如何修复错误TS2339:类型上不存在属性“ authToken”

  8. 8

    Express.js / Typescript:错误TS2339:类型“ Response”上不存在属性“ send”

  9. 9

    错误TS2339:类型“订阅”上不存在属性“订阅”

  10. 10

    角度:错误TS2339:类型“对象”上不存在属性“数据”

  11. 11

    角度:错误TS2339:类型“对象”上不存在属性“数据”

  12. 12

    错误TS2339:类型“ AngularFireAuth”上不存在属性“ auth”

  13. 13

    TypeScript错误TS2339:类型“ EventTarget”上不存在属性“ matches”

  14. 14

    错误TS2339:类型'PromiseLike <void>'上不存在属性'catch'

  15. 15

    错误 TS2339:类型“Angular2”上不存在属性“”

  16. 16

    错误 TS2339:类型“{}”上不存在属性“includes”

  17. 17

    错误 TS2339:“FormData”类型上不存在属性“entries”

  18. 18

    错误 TS2339:“导航器”类型上不存在“相机”属性

  19. 19

    错误 TS2339:类型“y[] 上不存在属性“x”

  20. 20

    错误 TS:2339 类型 {} 上不存在属性“项目”

  21. 21

    angular2:错误:(62,33)TS2339:类型'typeof Injector'上不存在属性'resolveAndCreate'

  22. 22

    打字稿| Array.from | 错误TS2339:类型“ ArrayConstructor”上不存在属性“来自”

  23. 23

    错误 TS2339:“对象”类型上不存在属性“JSON”。".map(resp => resp.JSON())" 角度 4

  24. 24

    如何解决 TypeScript 编译器错误 TS2339:我的 Angular 5 应用程序中的类型 {} 上不存在属性“errorValue”

  25. 25

    错误TS2339:类型'{新():控制台上不存在属性'log';原型:控制台;}'

  26. 26

    错误显示在我的 .ts 代码中 > [ts] 类型“any[]”上不存在属性“name”

  27. 27

    TS2339:类型“{}”上不存在属性“props”

  28. 28

    使用Typescript类型错误反应“自定义挂钩”“类型'interface |(({{target}:any)=> void)'。ts(2339)上不存在属性'x'

  29. 29

    useRef Typescript错误:类型“ HTMLElement”上不存在属性“当前”

热门标签

归档