Skip to content

Instantly share code, notes, and snippets.

@steve228uk
Forked from NickToye/gist:ab7b004d2c3889174417
Created October 22, 2015 08:02
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 steve228uk/5a8dc8bb00e99688c0ec to your computer and use it in GitHub Desktop.
Save steve228uk/5a8dc8bb00e99688c0ec to your computer and use it in GitHub Desktop.
(function(angular) {
'use strict';
angular.module('store', ['ngRoute'])
.controller('MainController', ['$scope','$route','$routeParams','$location', function($scope, $route, $routeParams, $location) {
$scope.$route = $route;
$scope.$location = $location;
$scope.$routeParams = $routeParams;
}])
.controller('StoreController', ['$scope', '$route', '$location', '$http', function($scope, $route, $location, $http) {
$scope.$route = $route;
$scope.$location = $location;
$scope.name = "StoreController";
$scope.store = {};
$http.get('//api.my.data.co.uk/api/store/').success(function(data){
$scope.store.stores = data;
});
store.submit = function() {
$http.get('http://api.my.data.co.uk/api/localstores/' + store.postcode).success(function(data){
store.stores = data;
});
};
}])
.config(function($routeProvider, $locationProvider) {
$routeProvider
.when('/storelocator', {
templateUrl: 'storelocator.html',
controller: 'StoreController'
})
.when('/Store/:storeId', {
templateUrl: 'store.html',
controller: 'StoreController'
});
// configure html5 to get links working on jsfiddle
$locationProvider.html5Mode(false);
});
})(window.angular);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment