Hi i am newbie to angularjs, I am developing registration form. in my form i have created_At field. But this field should be filled automatically with current date and time in format("2015-02-26T07:28:01.596Z").
i am able to get the date and time as but i am not getting how to set this value into form field.
am getting date as
here i am getting value below the field, but i want to set that time and date as createdAt field value..
here is my form code
<body ng-app="myApp">
<div class="form-group">
<label for="user_createdAt" class="col-sm-2 control-label">{{ 'user.createdAt' | translate }}</label>
<div ng-controller="MainCtrl" class="col-sm-10">
<input type="datetime-local" id="user_createdAt" ng-model="user.createdAt" name="createdAt" class="form-control" value= "{{ date | date: 'yyyy-MM-dd' }}" />
</br>{{ date }}
<br/>{{ date | date: 'yyyy-MM-dd' }}
</div>
</div>
</body>
can anyone help me! Thanks in advance
Set the corresponding ngModel
to date object and Angular will populate input field properly, just remove value
attribute. For example:
$scope.user.createdAt = new Date();
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.