Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Step 18.33: Create PartyAddButton component
- Loading branch information
Kamil Kisiela
authored and
Dotan Simha
committed
Nov 22, 2016
1 parent
f180e87
commit ab434aa
Showing
1 changed file
with
45 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
import angular from 'angular'; | ||
import angularMeteor from 'angular-meteor'; | ||
|
||
import buttonTemplate from './partyAddButton.html'; | ||
import modalTemplate from './partyAddModal.html'; | ||
import { name as PartyAdd } from '../partyAdd/partyAdd'; | ||
|
||
class PartyAddButton { | ||
constructor($mdDialog, $mdMedia) { | ||
'ngInject'; | ||
|
||
this.$mdDialog = $mdDialog; | ||
this.$mdMedia = $mdMedia | ||
} | ||
|
||
open(event) { | ||
this.$mdDialog.show({ | ||
controller($mdDialog) { | ||
'ngInject'; | ||
|
||
this.close = () => { | ||
$mdDialog.hide(); | ||
} | ||
}, | ||
controllerAs: 'partyAddModal', | ||
template: modalTemplate, | ||
targetEvent: event, | ||
parent: angular.element(document.body), | ||
clickOutsideToClose: true, | ||
fullscreen: this.$mdMedia('sm') || this.$mdMedia('xs') | ||
}); | ||
} | ||
} | ||
|
||
const name = 'partyAddButton'; | ||
|
||
// create a module | ||
export default angular.module(name, [ | ||
angularMeteor, | ||
PartyAdd | ||
]).component(name, { | ||
template: buttonTemplate, | ||
controllerAs: name, | ||
controller: PartyAddButton | ||
}); |