22

I am using angular-ui bootstrap datepicker. Now I need to remove #(week) column and week button from datepicker. This date picker is being used in many forms of my application. I want to remove week column from all of them.

For this, I had globally configured the datepickerConfig (show-weeks) but still it is not working. Can anyone please let me know I am doing wrong with this?

Dipesh Gandhi
  • 765
  • 1
  • 13
  • 31

6 Answers6

34

Please, look at this example: http://plnkr.co/edit/6i4G7JkvBiWXZYlrV2GL?p=preview

angular.module('app', ['ui.bootstrap'])
  .config(function (datepickerConfig) {
      datepickerConfig.showWeeks = false;
    });
Gm0t
  • 703
  • 7
  • 13
  • Thanks It's working. Do you know how to hide only weeks button from bottom? – Dipesh Gandhi Dec 20 '13 at 05:27
  • 2
    I looked at source for datepickerPopup, there is no possible way for doing this. You can use dirty hack and hide button with css instead, something like this: http://plnkr.co/edit/6i4G7JkvBiWXZYlrV2GL?p=preview ... but it's a very dirty hack %) – Gm0t Dec 20 '13 at 07:00
  • Thanks, It's okay for me. – Dipesh Gandhi Dec 21 '13 at 18:33
12

For datepicker in popup, datepicker-options attribute has value dateOptions in which json can be added for any datepicker settings as shown in the HTML below.

<input type="text" class="form-control" datepicker-popup="{{format}}" ng-model="dt" is-open="opened" min-date="minDate" max-date="'2015-06-22'" **datepicker-options="dateOptions"** date-disabled="disabled(date, mode)" ng-required="true" close-text="Close" />

In javascript this is given

 $scope.dateOptions = {
    formatYear: 'yy',
    startingDay: 1,
    
  };

just add showWeeks:false in dateOptions like this,

 $scope.dateOptions = {
    formatYear: 'yy',
    startingDay: 1,
    showWeeks:false
  };

or you can add like this 'show-weeks':'false' . Demo is shown at plunker [http://plnkr.co/edit/qbp3IObj13op2RS17IEg?p=preview][1]

shruti
  • 5,953
  • 1
  • 14
  • 12
  • This should be the accepted answer, because it only removes the weeks from this datepicker, not all datepickers in the application. – Claus Conrad Dec 22 '14 at 12:17
  • 2
    Thanks for the answer I think it's a cleaner solution than the accepted answer however showWeeks:'false' wouldn't work for me. I had to remove the single quotes and then it worked. – Schokea Mar 02 '16 at 12:12
  • Angular 1.5.6 I also had to remove the single quotes for it to work. – Adrian Carr Jun 24 '16 at 19:17
  • Thanks for help, however without single quotes solution is work. Thus, showWeeks:false is work in place of showWeeks:'false'. – Rahul Modi Mar 22 '17 at 04:59
4

If angular bootstrap ui version is 0.14.3, use the following

app.config(function (uibDatepickerConfig) {
    uibDatepickerConfig.showWeeks = false;
    uibDatepickerConfig.showButtonBar = false;
});
Bartłomiej Semańczyk
  • 59,234
  • 49
  • 233
  • 358
Suresh Velusamy
  • 2,338
  • 19
  • 24
0

If you want to do it directly in the template, simply add the following attribute to the input:show-weeks="false".

ValentinH
  • 928
  • 1
  • 11
  • 31
  • 3
    I've been trying to use the show-weeks attribute and it doesn't seem to work for me :( – robert.bo.roth May 12 '14 at 16:03
  • Well, I have it working at work but I can't reproduce in the demo plunker of documentation. It does work with the inline calendar but does't work for the popup. It might be linked with this issue: https://github.com/angular-ui/bootstrap/issues/1132 I'll check on Monday my code to see how I did it. – ValentinH May 17 '14 at 06:52
  • 2
    THIS would only work if you are using directive as an element such as if you are using – jeveloper Oct 15 '14 at 14:55
0

To hide the weeks number you can use two different way.

First one: adding into controller

$scope.dateOptions = {
    'year-format': "'yy'",
    'starting-day': 1   };

or Second way: add attribute in input field

show-weeks="'false'"
user45205
  • 21
  • 4
0

This should work

<input type="text" placeholder="mm/dd/yyyy" [bsConfig]="{showWeekNumbers:false}" />

or

<datepicker show-weeks='false' />
suresh
  • 73
  • 7