---
title: "Angular Scheduler Custom Range View Example | Mobiscroll"
component: "Scheduler"
framework: "Angular"
library_version: "6.2.0"
url: "https://demo.mobiscroll.com/angular/scheduler/custom-range-view"
---

# Custom Range View - Angular Scheduler demo

Configure the Angular Scheduler with a custom date range view — let users pick any date span from a header range picker instead of fixed day.

- [Live demo](https://demo.mobiscroll.com/angular/scheduler/custom-range-view)
- [View code on GitHub](https://github.com/acidb/mobiscroll-demos-angular/tree/main/src/demos/eventcalendar/scheduler/custom-range-view)
- This demo in other frameworks: [JavaScript](https://demo.mobiscroll.com/javascript/scheduler/custom-range-view.md), [jQuery](https://demo.mobiscroll.com/jquery/scheduler/custom-range-view.md), [React](https://demo.mobiscroll.com/react/scheduler/custom-range-view.md), [Vue](https://demo.mobiscroll.com/vue/scheduler/custom-range-view.md)

## Description

The scheduler comes with [built-in support for day, week and month views](https://demo.mobiscroll.com/angular/scheduler/display-multiple-days-weeks). For those situations where a custom range makes more sense, it is possible to override the calendar navigation component with a [range picker](https://demo.mobiscroll.com/angular/range/date-filtering-with-predefined-ranges).

The calendar header can be easily customized and a two-way synchronization needs to be kept between the scheduler and range picker.

## What this demo shows

- A desktop scheduler layout with a custom date range in the header, a fixed all-day row below it, and a vertically scrollable time grid for the selected range.
- **Header** The header shows the selected custom date range on the left. Clicking the displayed range opens an anchored range picker where users can choose a custom scheduler range instead of using only fixed day, week, month, or year views.
- **Header navigation** The previous and next controls and the Today button let users move through the scheduler range and return to the current day.
- **Custom range view** The fixed strip below the header displays the days in the selected range, with the current date highlighted.
- **All-day events** All-day events appear in a dedicated row that stays fixed above the time grid.
- **Time grid** The scheduler grid scrolls vertically through the hours of the selected custom range.
- **Timed events** Timed events appear as colored cards in the scheduler grid, showing the start and end time above the event title.
- **Event overlapping** Overlapping events are displayed side by side so every event remains visible.
- **Current time** A current-time indicator appears across the scheduler grid.
- **Hover behavior** Hovering over the time grid shows a time indicator that follows the cursor in 15-minute increments.
- **Event interaction** Hovering over events highlights them and displays drag and resize handles for editing.
- **Event creation** Users can create events by double-clicking the grid or by clicking and dragging across a time range.

## Best for

- **Conference and event planning** Coordinate multi-day conferences, trade shows, workshops, festivals, corporate events, meetings, and sessions.
- **Project and program management** Track project phases, milestones, launches, deadlines, and team activities across several weeks in a single scheduler view.
- **Business travel and itineraries** Plan business trips, tours, client visits, training programs, and travel schedules while keeping appointments visible.
- **Marketing and campaign planning** Manage campaigns, content schedules, product launches, promotional events, and key milestones over extended periods.

## API used in this demo

- [`theme`](https://mobiscroll.com/docs/angular/eventcalendar/api#opt-theme) - option
- [`themeVariant`](https://mobiscroll.com/docs/angular/eventcalendar/api#opt-themeVariant) - option
- [`refDate`](https://mobiscroll.com/docs/angular/eventcalendar/api#opt-refDate) - option
- [`selectedDate`](https://mobiscroll.com/docs/angular/eventcalendar/api#opt-selectedDate) - option
- [`view`](https://mobiscroll.com/docs/angular/eventcalendar/api#opt-view) - option
- [`onPageLoading`](https://mobiscroll.com/docs/angular/eventcalendar/api#event-onPageLoading) - event
- [`data`](https://mobiscroll.com/docs/angular/eventcalendar/api#opt-data) - option
- [`headerTemplate`](https://mobiscroll.com/docs/angular/eventcalendar/api#template-headerTemplate) - template
- [`select`](https://mobiscroll.com/docs/angular/datepicker/api#opt-select) - option
- [`display`](https://mobiscroll.com/docs/angular/datepicker/api#opt-display) - option
- [`showOverlay`](https://mobiscroll.com/docs/angular/datepicker/api#opt-showOverlay) - option
- [`touchUi`](https://mobiscroll.com/docs/angular/datepicker/api#opt-touchUi) - option
- [`buttons`](https://mobiscroll.com/docs/angular/datepicker/api#opt-buttons) - option
- [`onClose`](https://mobiscroll.com/docs/angular/datepicker/api#event-onClose) - event

## Code

### Component

```ts
import { CommonModule } from '@angular/common';
import { HttpClient } from '@angular/common/http';
import { Component, OnInit } from '@angular/core';
import { FormsModule } from '@angular/forms';
import {
  formatDate,
  MbscCalendarEvent,
  MbscDateType,
  MbscEventcalendarOptions,
  MbscEventcalendarView,
  MbscModule,
  setOptions,
} from '@mobiscroll/angular';

setOptions({
  theme: 'ios',
  themeVariant: 'light'
});

@Component({
  selector: 'app-root', 
  templateUrl: './app.component.html',
  standalone: true,
  imports: [CommonModule, FormsModule, MbscModule],
})
export class AppComponent implements OnInit {
  constructor(private http: HttpClient) {}
  startDate!: Date;
  endDate!: Date;
  refDate!: Date;
  selectedDate: MbscDateType = new Date();
  rangeValue: any = [];
  rangeText = '';

  myEvents: MbscCalendarEvent[] = [];
  view = 'calendar';
  calView: MbscEventcalendarView = {
    scheduler: {
      type: 'day',
      size: 14,
    },
  };

  calendarOptions: MbscEventcalendarOptions = {
    onPageLoading: (args) => {
      const end = args.lastDay;
      this.startDate = args.firstDay;
      this.endDate = new Date(end.getFullYear(), end.getMonth(), end.getDate() - 1, 0);
      // Set button text
      this.rangeText = this.getFormattedRange(this.startDate, this.endDate);
      // Set range value
      this.rangeValue = [this.startDate, this.endDate];
      // Navigate the calendar
      this.selectedDate = this.startDate;
    },
  };

  onClose(): void {
    const date = this.rangeValue;
    if (date[0] && date[1]) {
      // Navigate the calendar
      this.selectedDate = date[0];
      this.startDate = date[0];
      this.endDate = date[1];
      // Set calendar view
      this.refDate = date[0];
      this.calView = {
        scheduler: {
          type: 'day',
          size: this.getNrDays(date[0], date[1]),
        },
      };
    } else {
      this.rangeValue = [this.startDate, this.endDate];
    }
  }

  // Returns the formatted date
  getFormattedRange(start: any, end: any): string {
    return (
      formatDate('MMM D, YYYY', new Date(start)) +
      (end && this.getNrDays(start, end) > 1 ? ' - ' + formatDate('MMM D, YYYY', new Date(end)) : '')
    );
  }

  // Returns the number of days between two dates
  getNrDays(start: any, end: any): number {
    return Math.round(Math.abs((end.setHours(0) - start.setHours(0)) / (24 * 60 * 60 * 1000))) + 1;
  }

  ngOnInit(): void {
    this.http
      .jsonp<MbscCalendarEvent[]>('https://trial.mobiscroll.com/events/?vers=5', 'callback')
      .subscribe((resp: MbscCalendarEvent[]) => {
        this.myEvents = resp;
      });
  }
}
```

### Template

```html
<mbsc-eventcalendar
  [data]="myEvents"
  [view]="calView"
  [headerTemplate]="customTemplate"
  [options]="calendarOptions"
  [(selectedDate)]="selectedDate"
  [refDate]="refDate"
>
  <ng-template #customTemplate>
    <div
      [(ngModel)]="rangeValue"
      mbsc-datepicker
      select="range"
      display="anchored"
      [showOverlay]="false"
      [touchUi]="true"
      [buttons]="[]"
      (onClose)="onClose()"
    >
      <mbsc-button variant="flat" class="mbsc-calendar-button">
        <span class="mbsc-calendar-title">{{rangeText}}</span>
      </mbsc-button>
    </div>
    <div class="md-custom-range-view-controls">
      <mbsc-calendar-prev></mbsc-calendar-prev>
      <mbsc-calendar-today></mbsc-calendar-today>
      <mbsc-calendar-next></mbsc-calendar-next>
    </div>
  </ng-template>
</mbsc-eventcalendar>
```

### CSS

```css
.md-custom-range-view-controls {
  display: flex;
  flex: 1 0 auto;
  justify-content: flex-end;
  align-items: center;
}
```

## Implementation notes

- Use `view: { scheduler: { type: 'day', size: 14 } }` - a multi-day scheduler where `size` is the number of days shown simultaneously. The initial value is 14; it is updated dynamically whenever the user selects a new range.
- Render a custom header containing: a `Datepicker` in `select: 'range'` mode anchored to a button, a button displaying the formatted current date range, and `CalendarPrev`, `CalendarToday`, `CalendarNext` navigation controls.
- Configure the `Datepicker` with `display: 'anchored'`, `showOverlay: false`, `touchUi: true`, and `buttons: []` (no footer buttons). Anchor it to the date-range button element so it opens positioned directly below it.
- **Two-way sync**: On `onPageLoading` (React/Angular) or `onPageLoaded` (Vue/JS/jQuery), update the button text and datepicker range value to reflect the current calendar page. On datepicker `onClose`, calculate the number of days in the selected range, set `view.scheduler.size` to that count, and navigate the calendar to the range start date.
- Load events from `https://trial.mobiscroll.com/events/?vers=5` via JSONP using `getJson(url, callback, 'jsonp')`. React/Angular/Vue: assign the fetched array to the state/property bound to the `data` prop. JS/jQuery (imperative API): call `inst.setEvents(events)` in the callback.

## Run it in your project

1. If not signed up yet, or don't own a license, you can [start a free trial](https://mobiscroll.com/starttrial).

2. Clone the repository:

   ```
   git clone https://github.com/acidb/mobiscroll-demos-angular.git
   ```

3. If not installed yet, install the Mobiscroll CLI from NPM:

   ```
   npm install -g @mobiscroll/cli
   ```

4. Config Mobiscroll - open a terminal window in the root directory and run:

   ```
   mobiscroll config angular
   ```

5. Install dependencies - open a terminal window in the root directory and run:

   ```
   npm install
   ```

6. Run the project:

   ```
   ng serve
   ```

On a trial, add `--trial` to the config command: `mobiscroll config angular --trial`.

Running a demo locally requires a Mobiscroll trial or a license; setup is per framework at https://mobiscroll.com/docs/angular/getting-started/installation

## Related demos

- Next: [Limit Overlapping Events](https://demo.mobiscroll.com/angular/scheduler/control-number-of-concurrently-shown-events.md) - Set a max count or auto-fit overlapping events to available space in the Angular Scheduler — useful for appointment-heavy views.
