Editing day with Angularjs?

Asked

Viewed 34 times

-2

I have a screen where register days, times, among others and a screen to edit this data, if necessary. When I click on the button to edit such date I get the data right.

inserir a descrição da imagem aqui

The point is that on the edit screen I want the date field to be type=date, to appear the calendar and the person choose the new date, however, that way the date 20/09/2019 does not appear in the fields, only appears that the field is of the type text (type=text).

Someone knows how to adjust it?

Follows the html with the date field

<form name="formGrade">
    <div>
       Data
    </div>
    <div>
       <input class="form-control" type="date" 
              ng-model="agenda.data" 
              name="dia" id="" required />
    </div>
</form>

Javascript:

var getHorario = function(){
    var id = $scope.id;
    var idempresa = $scope.idempresa;
    var opcao = 'pegar horario';

    $http.get(getUrlOptionPrefix + opcao + '&id=' + id+ '&idempresa=' + idempresa)
      .then(function(response){
        $scope.agenda = response.data;
    })
}
getHorario();
  • of your code?

  • The html is there in the description! I don’t understand.

  • minimum and verifiable code, ie all problem code... Cade javascript?

  • I just posted...

  • 1

    This problem is because the date is coming in the wrong format (A questão é que na tela de edição eu quero que o campo data seja "type=date", para aparecer o calendário e a pessoa escolher a nova data, PORÉM, dessa forma a data "20/09/2019" não aparece no campos... Só aparece que o campo for do tipo text "type=text". Alguém sabe como ajustar isso?) would have to be 2019-06-20 for example https://jsfiddle.net/swh63fyk/

  • Now I got.... I followed the example of the link above. Thanks @Virgilionovic

Show 1 more comment

1 answer

0

You must convert the date to ISO format: yyyy-mm-dd

agenda.data = agenda.data.split('/').reverse().join('-');

Browser other questions tagged

You are not signed in. Login or sign up in order to post.