nw-card.js 1.0 KB

123456789101112131415161718192021222324
  1. angular.module("noteWrangler")
  2. .directive('nwCard', function () {
  3. return {
  4. retrict: "E", // "E" is for Element.
  5. templateUrl: "templates/directives/nw-card.html",
  6. /* By default, directives have "scope: false": they inherit from their
  7. parents, so setting properties on the scope actually sets them on the
  8. parent scope. Setting the scope to a non empty value creates an isolated
  9. scope for the child... so it no longer has access to the parent scope.
  10. So we pass the required parts of the parent scope to the directive in the
  11. HTML attributes (see notes.html). But then we can't use the inline
  12. controller, the directive needs to know it can receive a header from the
  13. notes.html template.
  14. */
  15. scope: {
  16. // "@" means we'll be passing header as a (1-way) string.
  17. // Also available: "=" (2-way binding, expression brackets no longer
  18. // needed around note.header) and "&".
  19. header: "=",
  20. icon: "=",
  21. },
  22. }
  23. });