Created
April 17, 2015 15:16
-
-
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.
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
$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