(function(angular) { "use strict"; var app = angular.module('Swagwise'); // Inject the CartService app.directive('addCartButton', function() { return { // E for Element // A for Attribute // C for Class restrict: 'E', scope: { // 3 types of bindings for scope properties // @ which is a string // & which is a one-way binding // = which is two-way binding }, replace: true, templateUrl: 'templates/add-cart-button.html', link: function(scope, elem, attr) { scope.addItem = function(item) { // Pass the item into the addItem method of the CartService }; } }; }); })(window.angular);