Skip to content

Instantly share code, notes, and snippets.

@cameron
Forked from ndhoule/floating-button-directive.js
Last active August 29, 2015 13:56
Show Gist options
  • Save cameron/8873569 to your computer and use it in GitHub Desktop.
Save cameron/8873569 to your computer and use it in GitHub Desktop.
var floatingButtonDirective = function() {
return {
restrict: 'AE',
scope: {
text: '@'
},
template: '<div class="floating-button">Text: {{ text }}</div>'
};
};
angular.module('App.FloatingButton')
.directive('floatingButton', floatingButtonDirective)
.constant("kEnableSiteFeedback", true)
.run([
'$compile',
'$rootElement',
'$rootScope',
function($compile, $rootElement, $rootScope, kEnableSiteFeedback) {
$rootScope.enableSiteFeedback = kEnableSiteFeedback;
// no longer necessary -- see snippet below
//var html = '<floating-button></floating-button>';
//var scope = $rootScope.$new();
//scope.text = 'test';
//$rootElement.append($compile(html)(scope));
}
]);
/* .... now we're in index.html */
<html>...
<feedback-button ng-if="enableSiteFeedback"></feedback-button>
...</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment