-
-
Save VanDalkvist/57a3612473f171a532c5 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| // ng-include-view | |
| // - directive in module ng | |
| // | |
| // This works similar to ng-include and it won't create new scope, | |
| // instead it uses the same level | |
| // | |
| // Example usage: | |
| // <ng-include-view src=""></ng-include-view> | |
| 'use strict'; | |
| angular | |
| .module('App', []) | |
| .directive('ngIncludeView', function($compile, $templateCache) { | |
| return { | |
| restrict: "EA", | |
| link: function($scope, elem, attrs){ | |
| var templateUrl = attrs.src; | |
| $scope.$watch(templateUrl, function(){ | |
| elem.html($templateCache.get(arguments[0])); | |
| $compile(elem.contents())($scope); | |
| }, true); | |
| } | |
| }; | |
| }); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment