Can I use $compile in an Angular service directly on a templateUrl instead of on raw HTML or a raw angular.element?
Given the following service that is meant to create a "dialog" element (i.e. a modal): app.service('dialog', ['$document', '$compile', '$rootScope', function($document, $compile, $rootScope) { var body = $document.find('body'); var scope = $rootScope.$new(); this.createDialog = function() { var dialogElem = angular.element('<div ng-include="\'/dialog.html\'"></div>'); $compile(dialogElem)(scope); body.append(dialogElem); }; } ]); which can be utilized in a controller like so: $scope.someFunction = function() { dialog.createDialog(); }; Is there a way that I can use $compile or anything else to