0

I am using jqueryUI date-picker for inputting the ReceivedByDate. But my ng-model for retrieving date value is always passing null value. I am working with asp.net mvc 4 with angularJs. Here is my code:

@Html.TextBoxFor(model => model.ReceivedByDate, new { autocomplete = "off", ng_model = "requisition.ReceivedByDate" })

<p>{{requisition.ReceivedByDate}}</p>

My script for datepicek is like this:

$(function () {
    $("#ReceivedByDate").datepicker({
        changeMonth: true,
        changeYear: true
    });
    $("#ReceivedByDate").datepicker("option", "dateFormat", "yy-mm-dd");
});

Although when I select a date but the value inside the "< p> < /p>" remains null. It seems always holding null. What wrong am I doing?

raisul
  • 640
  • 1
  • 5
  • 26
  • You need something like this https://github.com/angular-ui/ui-date. Basically one needs to create a directive. I highly recommend you try to read as much AngularJS documentation as possible. Angular is not a replacement for jquery hence you need to unlearn some stuff and learn new ways of doing stuff. See here too http://stackoverflow.com/questions/14994391/how-do-i-think-in-angularjs-if-i-have-a-jquery-background?rq=1 – Chandermani Aug 29 '13 at 09:02
  • Thanks for your suggesstion Chandermani. I've got a way to use JqeuryUI datepicker from here: http://jsfiddle.net/simpulton/WzEvs/ This is the extended version: http://www.abequar.net/jquery-ui-datepicker-with-angularjs/ – raisul Aug 29 '13 at 10:50
  • `ng_model` should be `ng-model` I guess? – Satpal Aug 29 '13 at 11:01
  • No Satpal, for Razorview the attributes that contains dash(-) is need to pass underscore(_) in place of dash(-). If you use dash(-) you will get error. – raisul Aug 29 '13 at 11:32

0 Answers0