问题
I have one sample with interpolation. It shows drop-down values correctly when is use any one event like below:
sample: click me
code snippet:
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'>
sample 2: click me
In this sample i would not add any event, in this case interolation is not working.
Code snippet:
<ejs-dropdownlist
required id="ddlApp" name="ddlApp"
[dataSource]='appDataSource' [allowFiltering]='true'
[itemTemplate]="itemTemplate" [valueTemplate]="valueTemplate"
[(ngModel)]="dropdownlApp" #ddlApp="ngModel"
[placeholder]='ddlAppText' [fields]='fields'>
回答1:
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' ]
})
Bind you object array in ngOnInit()
it is the right way to bind and right time to bind the values - Thanks, Happy coding !!
来源:https://stackoverflow.com/questions/53202531/angular-interpolation-is-not-working-properly