-
-
Save rippo/5468813 to your computer and use it in GitHub Desktop.
Controllers, directives and templates
This file contains 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 ng-app="App"> | |
<div ng-controller="AppCtrl"> | |
<products></products> | |
</div> | |
</div> |
This file contains 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
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", | |
}; | |
}); |
This file contains 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
<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