<quick-datepicker type="text" name='start_date' 
ng-model="repariment.start_date" required></quick-datepicker>

The above code is inside a form.

<script type='text/javascript'>
    app.config(function(ngQuickDateDefaultsProvider) {
        return ngQuickDateDefaultsProvider.set({
    app.controller("perbaikanController", function($scope) {
        $scope.myDate = null
        $scope.setToToday = function() { $scope.myDate = new Date(); }

When I submit the from and check the $repariment.start_date, it always return current datetime (maybe because null). At the backend (NodeJS), I can't get the value. How to make it work?


Paritosh February 2016

Use $scope.myDate in HTML markup

<quick-datepicker type="text" name='start_date' ng-model="myDate" required></quick-datepicker>

I think you are not using the correct scope variable

Zeeshan Hassan Memon February 2016

Problem seems here $repariment.start_date change it to $scope.myDate in HTML markup.

Fixed HTML:

<quick-datepicker type="text" name='start_date' ng-model="myDate" required></quick-datepicker>

Steve Goldberg February 2016

Since you left out your <ng-controller> tag, I can't be sure -- but it sounds like you need to use the controller as form of the ng-controller, e.g. in your HTML surrounding the control:

<div ng-controller="perbaikanController as repariment">

and in your controller, instead of $scope, you'd use this which will be bound to repariment thusly:

app.controller("perbaikanController", function() {
    this.myDate = null;
    this.setToToday = function() { this.myDate = new Date(); }

(That's, if I've understood what you're doing.) It makes it so instead of using $scope, you use the bound variable in the template.

A more complete code sample would make it easier to answer for sure.

Hope it helps.


Post Status

Asked in February 2016
Viewed 2,654 times
Voted 14
Answered 3 times


Leave an answer

Quote of the day: live life