Skip to content

Instantly share code, notes, and snippets.

@lukehedger
Created September 24, 2014 11:18
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 lukehedger/7b176e9a9e873386e19f to your computer and use it in GitHub Desktop.
Save lukehedger/7b176e9a9e873386e19f to your computer and use it in GitHub Desktop.
Simple Angular directive
'use strict';
// declare app-level module
var app = angular.module('app', []);
// register directive
app.directive('partial', function () {
return {
templateUrl: "partial.html", // url to template
restrict: "AE" // restrict directive trigger to attribute (A) and element (E), not classname (C)
}
});
<div>I'm a partial</div>
<!-- include the partial as an element -->
<partial></partial>
<!--or as an attribute -->
<div partial></div>
<!-- either way, the contents of partial.html will render inside the element -->
@lukehedger
Copy link
Author

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