Skip to content

Instantly share code, notes, and snippets.

@SerhiiKozachenko
Created August 6, 2013 21:54
Show Gist options
  • Save SerhiiKozachenko/6169081 to your computer and use it in GitHub Desktop.
Save SerhiiKozachenko/6169081 to your computer and use it in GitHub Desktop.
Angular directive with ng-repeat inside and cached templates.
'use strict';
(function() {
var categoryItem = function(templateCache){
return {
restrict: 'E',
replace: true,
transclude: false,
scope: { items:'=in'},
// Use templateCache instead of templateUrl
template: templateCache.get('category-item'),
// The linking function will add behavior to the template
link: function(scope, element, attrs) {
}
}
};
categoryItem.$inject = ['$templateCache'];
angular.module('MerchApp').directive('categoryItem', categoryItem);
})();
// Templates go here
ng-include(src="'/templates/template'")
!!! 5
html
head
script(type="text/ng-template", id="category-item")
.category-item.col-lg-3(ng-repeat="category in items")
.thumbnail
.caption
h3 {{category.title}}
p Category description
button.btn.btn-primary Details
body
.row
category-item(in="Categories")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment