Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Step 20.39: Create PartyImage component
- Loading branch information
Showing
1 changed file
with
37 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,37 @@ | ||
import angular from 'angular'; | ||
import angularMeteor from 'angular-meteor'; | ||
|
||
import template from './partyImage.html'; | ||
import { Images } from '../../../api/images'; | ||
|
||
class PartyImage { | ||
constructor($scope, $reactive) { | ||
'ngInject'; | ||
$reactive(this).attach($scope); | ||
|
||
this.helpers({ | ||
mainImage() { | ||
const images = this.getReactively('images', true); | ||
if (images) { | ||
return Images.findOne({ | ||
_id: images[0] | ||
}); | ||
} | ||
} | ||
}); | ||
} | ||
} | ||
|
||
const name = 'partyImage'; | ||
|
||
// create a module | ||
export default angular.module(name, [ | ||
angularMeteor | ||
]).component(name, { | ||
template, | ||
bindings: { | ||
images: '<' | ||
}, | ||
controllerAs: name, | ||
controller: PartyImage | ||
}); |