Skip to content

Instantly share code, notes, and snippets.

@auser
Forked from ndhoule/floating-button-directive.js
Created February 7, 2014 23:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save auser/8874082 to your computer and use it in GitHub Desktop.
Save auser/8874082 to your computer and use it in GitHub Desktop.
var floatingButtonDirective = function() {
return {
restrict: 'AE',
scope: {
contents: '@'
},
template: '<div><div class="floating-button">Text: {{ contents }}</div></div>'
};
};
angular.module('App', [])
.directive('floatingButton', floatingButtonDirective)
.run([
'$compile',
'$rootElement',
'$rootScope',
function($compile, $rootElement, $rootScope) {
var html = '<floating-button contents="{{contents}}"></floating-button>';
var holderEle = angular.element(html);
$rootElement.append(holderEle);
var scope = $rootScope.$new();
scope.contents = 'test';
$compile(holderEle)(scope);
$rootScope.$digest();
}
]);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment