Skip to content

Instantly share code, notes, and snippets.

@cladera
Last active August 29, 2015 14:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cladera/3c5f0dab7ee594bdb264 to your computer and use it in GitHub Desktop.
Save cladera/3c5f0dab7ee594bdb264 to your computer and use it in GitHub Desktop.
Google Analytics Experiments in AngularJS - productcontroller.js
'use strict';
angular.module('myStoreApp')
.controller('ProductController', ['$scope', '$routeParams','$http', '$window', function($scope, $routeParams, $http, $window){
$scope.variant = $window.variant;
$http.get('api.mystore.com/products/'+$routeParams.id)
.success(function(product){
$scope.product = product;
});
$scope.addToCart = function(){
//Add product to user's shopping cart
};
}]);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment