Ibrahim Shaikh Ibrahim Shaikh - 1 month ago 7
AngularJS Question

angularjs unable to initialize date

I am creating a web app in which i want to update the date of a record

<td style=" border: 1px solid black; padding: 3px; text-align: center">
<div class="left-margin form-control-wrapper form-group has-feedback has-feedback" style="" >
<input type="text" class="date form-control floating-label" ng-model="udate" ng-init="udate='{{updateparam.Date}}'" value="{{updateparam.Date}}" CssClass="txttopborder font" Style="height:30px;" placeholder="Date" />
</div>
</td>


this is my date with calendar,
i want to initialize the previous value of my textbox, textbox is initializing the date properly but when i click on update, the following error message is coming

System.FormatException: String was not recognized as a valid DateTime.


when i print the value of my textbox like
{{udate}}
the value which should be printed is date but instead
{{updateparam.Date}}
this is printing when i edit the date then the date is prinitng, which means when i want to update a entry i must edit a date, but i don't want to edit the date all the time, what i need to do here?

Answer

do this in your controller

$scope.data = {
    udate="";
}

and replace this with text

<input type="text" class="date form-control floating-label" ng-model="data.udate" placeholder="Date" text="" height="30" CssClass="txttopborder font" />

in scenerio like these never use ng-init

Comments