Created
September 24, 2014 11:18
-
-
Save lukehedger/7b176e9a9e873386e19f to your computer and use it in GitHub Desktop.
Simple Angular directive
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'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) | |
} | |
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<div>I'm a partial</div> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!-- 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 --> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Resources: