Skip to content

Instantly share code, notes, and snippets.

@byverdu
Last active May 30, 2017 22:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save byverdu/d4836d365d8466400538bf93a0991e17 to your computer and use it in GitHub Desktop.
Save byverdu/d4836d365d8466400538bf93a0991e17 to your computer and use it in GitHub Desktop.
// 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