【问题标题】:Angular 4 - TypeError: this.changeHook is not a functionAngular 4 - TypeError:this.changeHook 不是函数
【发布时间】:2018-03-19 18:53:06
【问题描述】:

![image or error ]1Angular 4 应用程序每当我在输入文本框中输入 TypeError: this.changeHook is not a function - 消息显示在控制台中。我无法弄清楚这个错误是什么。有任何想法吗。

****更新**** 它仅适用于第二个输入文本框,不适用于第二个输入文本框。 一旦我输入第二个输入框,输入的字符数,控制台中就会显示许多带有相同消息的错误。

HTML

 <ng-container *ngFor="let reasoncode of displayReasonCodes$ | async;let i = index">
 <tr class= "row-break">

 <checkbox type="checkbox"  name="sizecb[]" value="{{reasoncode.id}}"  [(ngModel)]="reasoncode.state">
      </checkbox>


       <td>  
          <form>
           <form-group>

  <textbox [readOnly]="isEditable" ngModel="{{reasoncode.ReasonCode}}"  name="textbox" ></textbox>
                                            </form-group>

                                    </form>

                            </td>
                            <td>
                                                     <form>
                                                            <form-group>

                                                              <textbox ngModel="{{reasoncode.Description}}" name="textbox1" ></textbox>
                                                            </form-group>

                                                    </form>

                            </td>

组件-

       @Component({
    selector: 'app-reason-codes',
    templateUrl: './reason-codes.component.html',
    styleUrls: ['./reason-codes.component.scss'],
    providers: [ ReasonCodesActions],
    encapsulation: ViewEncapsulation.None,

  })


  export class ReasonCodesComponent implements OnInit {
    poolModel: ReasonCodeFormUIModel;



    IReasonCodes: IReasonCodes[]=[]; 


    i:any;
    @select(store.isReasonCodeLoading) isLoading$: Observable<boolean>;
    @select(store.displayReasonCodes) displayReasonCodes$:Observable<IReasonCodes>;
    @select(store.isDisplayMessage) displayMessage$: Observable<boolean>;
    @select(store.componentType) componentType$: Observable<number>;


    Active:any;




    addCodes:boolean;
    state:any;
     $event:any;
    displayReasonCodes:any;



    headers = [
        { label: 'REASON CODES ', sort: false },
        { label: 'DESCRIPTION', sort: false },
        { label: 'STATUS', sort :false}
      ];


      constructor(private reasonCodesActions : ReasonCodesActions,
        private uiActions:UIActions) {
      }

    ngOnInit (){



       this.displayReasonCodes$.subscribe(data=>this.result=data); 



     this.reasonCodesActions.getReasonCodes();

    }






      Addrow(){ console.log("add");
      this.isEditable=false;
        this.reasonCodesActions.Addrow();
      }


      refresh(){
        location.reload();
      }                   

【问题讨论】:

  • 能否请您显示导致错误的代码?
  • 请与输入的 html 和包含它的组件共享您的代码。
  • @edkeveked - 更新
  • @Narm - 更新
  • @user8819437 请考虑进行格式化以方便阅读:)

标签: angular typescript


【解决方案1】:

发现问题 - 我没有在模板的输入框中使用任何输入属性。所以它无法识别输入。一旦我添加了输入属性,错误就从控制台消失了。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-07-17
    • 2018-07-08
    • 1970-01-01
    • 2020-01-10
    • 2015-09-01
    • 2018-03-19
    相关资源
    最近更新 更多