Skip to content
This repository was archived by the owner on Sep 5, 2024. It is now read-only.

Conversation

crisbeto
Copy link
Member

  • Allows users to set the default open view of the calendar via the md-current-view attribute.
  • Removes a few unused dependencies from the datepicker.

Fixes #9111.

* Allows users to set the default open view of the calendar via the `md-current-view` attribute.
* Removes a few unused dependencies from the datepicker.

Fixes angular#9111.
@crisbeto crisbeto added the needs: review This PR is waiting on review from the team label Jul 22, 2016
@@ -57,7 +57,8 @@
scope: {
minDate: '=mdMinDate',
maxDate: '=mdMaxDate',
dateFilter: '=mdDateFilter'
dateFilter: '=mdDateFilter',
_currentView: '@mdCurrentView'
Copy link
Member

@devversion devversion Jul 22, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you not make this optional and do in the controller?

this.currentView = this.currentView || 'month';

This would drop the unnecessary variable

I read the comment below, but I can't really see the point here.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tried it out, but for some reason the datepicker kept resetting it after the calendar was opened. E.g. here's what I tried:

var self = this;

console.log(self.currentView); // logs properly

setTimeout(function() {
  console.log(self.currentView); // logs an empty string 
});

It's weird, because it doesn't happen if I switch it to a two-way binding or I also add this.currentView = this.currentView || 'month'; to the datepicker's controller. I went with the underscored property in order to keep all the currentView logic within the calendar.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, I can't really understand why this is resetted. Isn't the currentView method only called after some interactions?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can't understand it either, the only time something interacts with it is when passing it through the template. My initial guess was because the calendar pane gets transferred from being a child of the datepicker to being directly in the body, but it still happened even after disabling it.

Copy link
Member

@devversion devversion Jul 22, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pretty weird. Not sure if you want to invest some more time, but you could possibly try to hook into that variable and try to figure out where it was changed from.

But other than that, the changes look fine :)

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
needs: review This PR is waiting on review from the team
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants