1
Hello, I’m having a problem in an angular application 2, I have 2 datepicker
<input type="text" data-date-format="dd/mm/yyyy" class="form-control pull-right" ng-model="ctrl.campanha.dataInicial" id="datepicker1" ng-init="initDatepicker1()">
<input type="text" data-date-format="dd/mm/yyyy" class="form-control pull-right" ng-model="ctrl.campanha.dataFinal" id="datepicke2" ng-init="initDatepicker2()">
I’m initiating them into my Controller by means of the following methods
$scope.initDatepicker1 = function () {
$('#datepicker1').datepicker({
autoclose: true
})
}
$scope.initDatepicker2 = function () {
$('#datepicke2').datepicker({
autoclose: true
})
}
function validacoes() {
console.log(vm.campanha.dataInicial)
console.log(vm.campanha.dataFinal)
return true
}
When I try to regain the values of Datepicker through the function validacoes()
, which is called by means of a ng-click they appear as Undefined, despite appearing within the input the values, see:
how can I solve this problem ?
try
console.log($scope.ctrl.campanha.dataInicial);
andconsole.log($scope.ctrl.campanha.dataFinal);
– NoobSaibot
I just tried... result: "Undefined"
– Matheus Freitas
Good morning Matheus, the code presented by you is Angular 1, I advise you to improve your description so that other people can help you.
– Eduardo Binotto