1

Problem Question - I am trying to build a directive for the datepicker. But somehow it is not showing the calender popup box. I have tried and looked into most of the post out there. I know it something simple but can't figure this out. Below is my directive

  angular.module('App').directive('myDatePicker',function(){
    return{
        restrict: 'AE',
        template:'<input is-open="opened" type="text" datepicker-popup="d/m/yyyy" ng-model="Date" ng-required="true" />'+
                   '<button type="button" ng-click="open()"></button>',

        controller: function($scope){

            $scope.open = function () {
                $scope.opened = true;
                console.log('I am working');
            };
        }
    };
});

HTML

<div my-date-picker></div>

Please guide me where I am making mistake.

GeekOnGadgets
  • 941
  • 3
  • 14
  • 47
  • Your forgot to add 'ui.bootstrap' module as a dependancy. Try to change your "angular.module('App')" into "angular.module('App', ['ui.bootstrap'])". – themyth92 Nov 14 '14 at 10:13
  • 1
    For full working example, please take a look at this working fiddle http://jsfiddle.net/themyth92/u1ggxt1j/. There is also a problem about scope related things which solution can be found here : http://stackoverflow.com/questions/23474054/angularjs-datepicker-not-opening-twice-angular-ui-version-0-11-0 – themyth92 Nov 14 '14 at 10:31
  • @themyth92 there is a problem in your fiddle, the month does not get displayed at all. – GeekOnGadgets Nov 20 '14 at 01:58
  • Hmm, I still saw the month on the fiddle. Can you please recheck ? – themyth92 Nov 20 '14 at 02:30
  • Nope its not there. it comes out as 20/0/2014. – GeekOnGadgets Nov 20 '14 at 02:58
  • For the fix you have to - datepicker-popup="d/MM/yyyy" – GeekOnGadgets Nov 20 '14 at 02:59
  • Ahh ok thanks for the fix. I have updated the fiddle http://jsfiddle.net/themyth92/u1ggxt1j/1/ but it is not a big problem though :) – themyth92 Nov 20 '14 at 03:11

0 Answers0