1

我正在编写一个角度应用程序,我想根据 Kendo Date Picker 的更新值调用 API。Kendo Date Picker 绑定到 Angular 模型但是,在更改日期后,我在模型变量中获得了相同的旧值(最初分配的值)。以下是我正在使用的 Typescript 和 HTML 代码。我错过了什么吗?

HTML:

 <input id="datepicker"  kendo-datepicker k-ng-model="StartDate" value="{{StartDate}}" />
 <button type="button" class="btn btn-primary" (click)="save();">Save</button>

代码:

export class AdminPeriodConfigurationComponent {
    StartDate: any;
    constructor(private _router: Router, private _globalService: GlobalService){
    }

    loadData(){
       this.StartDate="09/28/2016";// format is "mm-dd-yyyy" and this value binds to datepicker
    }

    ngOnInit() {
       this.loadData();
    }

    save(){
       var myobj=new MyClass();
       myobj.NewSelectedDate=this.StartDate; // here the updated value does not get assigned.
    }
}
4

0 回答 0