Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save shengoo/0186e068c4c853d703b2 to your computer and use it in GitHub Desktop.
Save shengoo/0186e068c4c853d703b2 to your computer and use it in GitHub Desktop.
use $compile outside a directive in Angularjs
$(function() {
// myApp for test directive to work, ng for $compile
var $injector = angular.injector(['ng', 'myApp']);
$injector.invoke(function($rootScope, $compile) {
$('body').prepend($compile('<div ng-attr-tooltip="test">Cancel</div>')($rootScope));
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment