angular - Error with DatePicker -
i have application in angular 2 typescript.
now, task <input />
tag type="date"
, , add tag <input type="date">
[value]
.
my value data server, data http-service (get
).
something this: <input type="date" [value]="...">
know <input type="date">
require string, , create interface in component:
export interface idatetime { createdat: string; }
and of course add property in component:
public datetime: idatetime = {createdat: ""};
finally, in template add tag:
<input class="form-control" type="date" [value]="idatetime.createdat"/>
and i've got error: cannot read property 'createdat' of undefined
. tell me please, why cannot read property, , how solve problem.
thank you.
you aren't binding variable declared in component, rather attempting bind interface declaration's property. bind variable instead need have [value]="datetime.createdat"
Comments
Post a Comment