Skip to content

Instantly share code, notes, and snippets.

@rippo
Created April 26, 2013 17:17
Show Gist options
  • Save rippo/5468813 to your computer and use it in GitHub Desktop.
Save rippo/5468813 to your computer and use it in GitHub Desktop.
Controllers, directives and templates
<div ng-app="App">
<div ng-controller="AppCtrl">
<products></products>
</div>
</div>
var app = angular.module('App', []);
app.controller("AppCtrl", function($scope, $http) {
$http.get('/api/products')
.then(function(res) {
$scope.products = res.data;
});
});
app.directive("products", function () {
return {
restrict: "E",
templateUrl: "/templates/products.html",
};
});
<h1>Products from template</h1>
<ul>
<li ng-repeat='product in products'>{{product.Name}} - <em>{{product.Category}}</em></li>
</ul>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment