Advertisement
Guest User

Untitled

a guest
Aug 31st, 2015
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.66 KB | None | 0 0
  1. angular.module('directives').directive('yourDirective', [function() {
  2. return {
  3. templateUrl: function($element, $attrs) {
  4. // Default template path.
  5. var templateUrl = 'partials/default.html';
  6.  
  7. // Check if a template url attribute has been passed in to the
  8. // directive. If one has been provided then make use of this
  9. // rather than the default.
  10. if ($attrs.templateUrl !== undefined) {
  11. templateUrl = $attrs.templateUrl;
  12. }
  13.  
  14. return templateUrl;
  15. }
  16. };
  17. }]);
  18.  
  19. // Example usage: <div data-your-directive data-template-url="'partials/other.html'"></div>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement