本文介绍了角度插值不正常?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个带插值的样本。当使用如下所示的任何一个事件时,它会正确显示下拉值:

I have one sample with interpolation. It shows drop-down values correctly when is use any one event like below:

代码段:

这里我添加了事件(open)=onOpen( )

Here i have added event (open)="onOpen()"

<ejs-dropdownlist 
    (open)="onOpen()"
    required id="ddlApp" name="ddlApp" [dataSource]='appDataSource' [allowFiltering]='true' 
    [itemTemplate]="itemTemplate" [valueTemplate]="valueTemplate" [(ngModel)]="dropdownlApp" 
    #ddlApp="ngModel" [placeholder]='ddlAppText' [fields]='fields'>



在此示例中,我不会添加任何事件,在这种情况下,内容无效。

代码摘录

<ejs-dropdownlist 
   required id="ddlApp" name="ddlApp" 
   [dataSource]='appDataSource' [allowFiltering]='true' 
   [itemTemplate]="itemTemplate" [valueTemplate]="valueTemplate" 
   [(ngModel)]="dropdownlApp" #ddlApp="ngModel" 
   [placeholder]='ddlAppText' [fields]='fields'>


推荐答案

只需删除 changeDetection:ChangeDetectionStrategy .OnPush 形成您的 @Component 装饰器,您的第二个样本将起作用

Just remove changeDetection: ChangeDetectionStrategy.OnPush form your @Component decorator your second sample will work

您的组件装饰器应该读作

You component decorator should read as

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

将对象数组绑定在 ngOnInit()这是绑定和正确时间绑定值的正确方法 - 谢谢,快乐编码!!

Bind you object array in ngOnInit() it is the right way to bind and right time to bind the values - Thanks, Happy coding !!

这篇关于角度插值不正常?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-14 21:32