edit.js:
import Controller from '@ember/controller';
import { computed } from '@ember/object';
export default Controller.extend({
sighting: computed.alias('model.sighting'),
sightingDate: computed.alias('model.sighting.sightedAt'),
actions: {
update() {
this.set('sightingDate', new Date(this.sighting.sightedAt));
if (this.sighting.get('hasDirtyAttributes')) {
this.sighting.save().then(() => {
this.transitionToRoute('sightings');
});
}
}
......
in edit.hbs:
<div class="form-group">
<label>date</label>
{{input value=sightingDate type="date" class="form-control"
name="sightedAt" required=true}}
</div>
but only a problem is: when form is loaded, input will display a text (mm/dd/yyyy) not sightedAt value !!!