Skip to content

Instantly share code, notes, and snippets.

@ryanhamley
Created April 17, 2015 15:16
Show Gist options
  • Save ryanhamley/21e26df337816cedcf72 to your computer and use it in GitHub Desktop.
Save ryanhamley/21e26df337816cedcf72 to your computer and use it in GitHub Desktop.
Snippet for including a template in an Angular attribute directive. This is useful for creating autocompletes, datepickers and other functionality that requires dynamically adding DOM elements to an existing element. This code would go inside of the directive's linking function.
$http.get('/views/includes/datepicker.html', {
cache: $templateCache
}).success(function(template) {
element.after($compile(template)(scope));
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment