-
-
Save steve228uk/5a8dc8bb00e99688c0ec to your computer and use it in GitHub Desktop.
This file contains hidden or 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
(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