Skip to content

Instantly share code, notes, and snippets.

@bclinkinbeard
Created February 6, 2014 21:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save bclinkinbeard/8853209 to your computer and use it in GitHub Desktop.
Save bclinkinbeard/8853209 to your computer and use it in GitHub Desktop.
Self contained directive
'use strict';
var angular = require('angular');
function LoginFormDirective ($compile) {
return {
restrict: 'E',
link: function (scope, element) {
var el = angular.element(require('./loginFormTemplate.html'));
el = $compile(el)(scope);
angular.element(element[0]).append(el);
}
};
};
LoginFormDirective.$inject = ['$compile'];
module.exports = LoginFormDirective;
@trevordixon
Copy link

Why not this?

return {
    restrict: 'E',
    template: require('./loginFormTemplate.html'),
    link: function (scope, element) {
        // template already compiled!
    }
};

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment