Skip to content
This repository has been archived by the owner on Jun 19, 2018. It is now read-only.

Access to parent scope/controller in #415

Closed
bignall opened this issue Aug 5, 2016 · 2 comments
Closed

Access to parent scope/controller in #415

bignall opened this issue Aug 5, 2016 · 2 comments
Milestone

Comments

@bignall
Copy link

bignall commented Aug 5, 2016

The github issues tracker is for bug reports and feature requests ONLY. Please use stackoverflow or read the documentation and examples for support issues, as well as checking previous issues.

Issues that ignore this template will be closed without notice!

Bug description / Feature request:

I used a custom template for the calendarMonthCell. To do what I needed, I needed access to functions in the controller for the parent scope. I couldn't find any options that allowed that, so I wanted to make a feature request for one. Here's how I solved it:

In the mwlCalendar directive I added to the scope:

parentCtl: '=?'

In the mwlCalendarMonth directive I added to the scope:

 parentCtl: '=?'

(You could add it to the other view directives too, but I am only using the month view)

In the template for the month view that uses the mwl-calendar-month directive I added:

   parent-ctl=\"vm.parentCtl\"

(Again you could do the same thing in the other view templates.)
Then I used the mwl-calendar directive like so:

<div ng-controller="MyCalendarController as cal">
        <mwl-calendar
            view="cal.calendar.view"
            view-date="cal.calendar.date"
            events="cal.events.list"
            view-title="cal.calendar.title"
            custom-template-urls="{calendarMonthCell: 'customMonthCell.html'}"
            cell-is-open="cal.calendar.cellIsOpen"
            slide-box-disabled="true"
            parent-ctl="cal"
        >
        </mwl-calendar>
</div>

And in my custom template I was able to access the parent controller via vm.parentCtl.

There might be a better way to do this via transclusion but I had trouble doing it that way because I then also needed transclusion in the view directives and it caused conflicts. I'm open to other possibilities though. I think this would be a really good addition to angular-bootstrap-calendar.

Great job with angular-bootstrap-calendar. It works really well!

Link to minimally-working plunker that reproduces the issue (starter template: http://plnkr.co/edit/LE4F4U7AnnD3tjM9ZH4G?p=preview)

Versions

Angular: 1.5.7

Calendar directive: 0.22.0

Browser name and version:

BTW, this was done as part of my work for Social and Scientific Systems and you can reach me at [email protected] regarding it.

@mattlewis92
Copy link
Owner

Seems like a reasonable request, I'll get this implemented this weekend 😄

@mattlewis92 mattlewis92 added this to the 0.23.x milestone Aug 5, 2016
@bignall
Copy link
Author

bignall commented Aug 5, 2016

Great! Thanks!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants