Reputation: 167
I want to display the current time on the display (hours and minutes). How can I do it most efficiently in terms of performance. I'm Using this technique for solve my question. Please help me.
time: function (data: any) {
debugger
console.log(`Now`);
return {
field: '<input class="form-control" type="time" value="13:30"/>',
};
},
time: {
onadd: (fld) => {
this.controlAdded(fld)
}
},
I attached my UI. I want to do display current time.
Upvotes: 1
Views: 9476
Reputation: 1163
Add following code in to your component ts file
now: string;
constructor() {
setInterval(() => {
this.now = new Date().toString().split(' ')[4];
}, 1);
}
& use this as this html code
<input type="text" value={{now}}/>
For more details refer these
1. Angular 4 display current time
2. https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date
Hope this works for u :)
Upvotes: 5