question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

"You did not provide a ViewContainerRef. " exception due calling selectDate

See original GitHub issue

A "You did not provide a ViewContainerRef. " exception is thrown when calling selectDate.


    "@angular-mdl/core": "^4.0.3",
    "@angular-mdl/datepicker": "0.0.2",
    "@angular-mdl/popover": "^0.6.3",
    "@angular-mdl/select": "^0.10.4",

 <button mdl-button (click)="pickADate($event)" mdl-button-type="icon" mdl-ripple>
    <mdl-icon>event</mdl-icon>
 </button>
 <span>{{ selectedDate?.format('LL') }}</span>

import { MdlDatePickerService } from '@angular-mdl/datepicker';
import * as moment from 'moment';

 constructor(
    private datePicker: MdlDatePickerService) { }

  public pickADate($event: MouseEvent) {
    this.datePicker.selectDate(this.selectedDate, { openFrom: $event }).subscribe((selectedDate: Date) => {
      this.selectedDate = selectedDate ? moment(selectedDate) : null;
    });
  }

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:5 (1 by maintainers)

github_iconTop GitHub Comments

1reaction
charitharumapperumacommented, May 16, 2017

Actually I found out that app should import MdlDialogModule at the root level for date picker to work (importing it in a sub module won’t work). I could not find that information in the given documentation. Even though that is straight forward to import it, I think that should be included in the documentation to be on the safe side.

0reactions
charitharumapperumacommented, Dec 27, 2017

MdlDialogModule must be imported as MdlDialogModule.forRoot() in app.module.ts

Read more comments on GitHub >

github_iconTop Results From Across the Web

Anguler2 - Unhandled Promise rejection: No provider for ...
What you can do is to inject ViewContainerRef and a service to a component and then in the constructor pass the ViewContainerRef to...
Read more >
ViewContainerRef - Angular
Anchor element that specifies the location of this container in the containing view. Each view container can have only one anchor element, and...
Read more >
Understanding ViewContainerRef in Angular 2 - Netanel Basal
When you need to add new DOM element (i.e., component, template) you need a place to insert the element. Angular is not magic;...
Read more >
UNPKG - @angular/material
If the tabs are not ready yet, we assume that the user is\n * providing a valid ... TemplateRef, ViewContainerRef} from '@angular/core';\nimport {CdkPortal} ......
Read more >
[angular] All about the ViewContainerRef - Medium
Note, that ng-template also can provide viewContainerRef and that's how we can create structural directive. @Component({ selector: 'my-app',
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found