Skip to content

Instantly share code, notes, and snippets.

@tylerdmace
Last active August 29, 2015 14:25
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 tylerdmace/016a73cdcc7368760d6a to your computer and use it in GitHub Desktop.
Save tylerdmace/016a73cdcc7368760d6a to your computer and use it in GitHub Desktop.
{{::bindOnce}}
'use strict';
module.exports = function(ngModule) {
ngModule.directive('myDirective', [function() {
var elementId = 0;
return {
restrict: 'E',
scope: {
data: '='
},
template: '<div id="{{::uniqueId}}"></div>',
replace: true,
link: function(scope, element, attrs) {
scope.uniqueId = 'unique-element-' + elementId++;
// Once the DOM is ready...
element.ready(function() {
somethingThatRequiresAnElementId(scope.uniqueId);
}
}
};
}]);
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment