Skip to content

Instantly share code, notes, and snippets.

@cdbattags
Created August 2, 2019 19:44
Show Gist options
  • Save cdbattags/7124fb0f198e10964e063d72f74fca53 to your computer and use it in GitHub Desktop.
Save cdbattags/7124fb0f198e10964e063d72f74fca53 to your computer and use it in GitHub Desktop.
Angular 1.x Injected
const inject = (element, state, template) => {
const injected = angular.element(element).injector()
injected.invoke(['$compile', '$rootScope', ($compile, $rootScope) => {
scope = angular.extend($rootScope.$new(), { $ctrl: state });
el.replaceWith($compile(template)(scope));
}]);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment