2

I'm using Angularjs. In that I'm using jquery for datepicker; but when I'm passing the selected date value it is not fetching the selected value. I need a solution for this problem.

Find below my code:

Markup

<div class="form-group">
    <label for="inputPassword3" class="col-sm-3 control-label">Project Startdate</label>
    <div class="col-sm-9">
        <!--   <input type="text" name="prjstartdate" id="prjstartdate" class="form-control" ng-model="vm.user.prjstartdate" required />-->
        <div class="container" id="sandbox-container">
            <div class="input-daterange input-group" id="datepicker" name="prjstartdate" id="prjstartdate" class="form-control" ng-model="vm.prjstartdate">
                <input type="text" name="prjstartdate" id="prjstartdate" class="form-control" ng-model="vm.prjstartdate" required />
            </div>
        </div>
        <span ng-show="form.password.$dirty && form.password.$error.required" class="help-block">Password is required</span>
    </div>
</div>

Function:

function MyCntrlsave($scope,$http) {

    $scope.savedetails = function() {
        var vm = this;
        var projectname = $scope.vm.prjname;
        var cilentname = $scope.vm.clientname;
        var clientstatus = $scope.vm.prjsta;
        var prjstartdate = $scope.vm.prjstartdate;
        var prjenddate = $scope.vm.prjenddate;
        var prjurl = $scope.vm.prjurl;
        alert("projectname"+projectname);
        alert("cilentname"+cilentname);
        alert("prjstartdate"+prjstartdate);
    };

};
0

1 Answer 1

4

HTML

<input type="text" name="prjstartdate" id="prjstartdate" class="form-control" ng-model="prjstartdate" required jqdatepicker/>

In controller

var prjstartdate = $scope.prjstartdate

Use jQuery UI and add a directive

datePicker.directive('jqdatepicker', function () {
return {
    restrict: 'A',
    require: 'ngModel',
     link: function (scope, element, attrs, ngModelCtrl) {
        element.datepicker({
            dateFormat: 'dd/mm/yy',
            onSelect: function (date) {
                scope.prjstartdate = date;
                scope.$apply();
            }
        });
    }
}; 
});

Demo Here

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.