I am new to Angularjs and I am working with a datepicker in Ionic. After selecting a date, the input field is correctly getting the value of the selected date. However, I am facing an issue when trying to access this value in the Controller using $scope.
Below is my HTML code:
<div class="list">
<label class="item item-input">
<input type="text" data-ng-model="dateValue" disabled>
</label>
</div>
<my-calendar display="dateValue" dateformat="'yyyy-MM-dd'"></my-calendar>
<button id="fieldWork-button21" data-ng- click="saveFieldWork(fieldWork)"></button>
After submitting, I am calling the save function where I bind other values with the fieldWork object.
Here is my Controller.js code:
$scope.dateValue = "";
$scope.saveFieldWork = function(fieldWork) {
fieldWork.fieldDate = $scope.dateValue;
//other code
};
Although the correct date is displaying in the input field after selection, I am unable to retrieve the selected date value in the Controller. It currently shows an empty string instead. Can someone explain how to successfully obtain this value in the Controller? If AngularJS supports two-way data binding, why am I experiencing difficulties retrieving the ng-model value from HTML to the Controller?