Created
September 15, 2014 19:52
-
-
Save B-Stefan/577f6c638d9abeaff30f to your computer and use it in GitHub Desktop.
An Angular-Directive to import a template and maintain the Scope
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
define ['./directives'], (module)-> | |
module.directive 'staticInclude', ($http, $templateCache, $compile)-> | |
(scope, element, attrs)-> | |
templatePath = attrs.staticInclude ? attrs.src; | |
$http.get(templatePath, { cache: $templateCache }).success (response)-> | |
contents = element.html(response).contents(); | |
$compile(contents)(scope) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Simple Angular Directive to keep the current scope an alternative for ngInclude