Last active
May 30, 2017 22:59
-
-
Save byverdu/d4836d365d8466400538bf93a0991e17 to your computer and use it in GitHub Desktop.
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
// app/client/js/services/directive.js | |
export function buildImdbCard() { | |
return { | |
restrict: 'E', | |
replace: true, | |
templateUrl: './views/imdbItem', | |
scope: { | |
data: '<', | |
callAction: '&', | |
textBtn: '@' | |
} | |
}; | |
} | |
// app/client/views/imdbItem.pug | |
// imdbItem.pug, usaremos ng-if para mostrar unos elementos u otros | |
// dependiendo donde estemos utilizando esta directiva | |
.imdb-card | |
h2 | |
a(ng-if="data._id", ng-href="{{data.itemurl}}") {{data.title}} - {{data.rating}} | |
a(ng-if="!data._id", ng-href="{{data.imdburl}}") {{data.title}} - {{data.rating}} | |
h3(ng-if="data.myRating") My rating: {{data.myRating}} | |
img(ng-src="{{data.poster}}", alt="poster {{data.title}}") | |
p {{data.description}} | |
a(ng-if="data._id", ng-href="{{data.imdburl}}") Visit imdb page for {{data.title}} | |
ul | |
li(ng-repeat="gen in data.genre") {{gen}} | |
button(ng-click="callAction()") {{textBtn}} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment