Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
(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";
var store = this;
$http.get('//api.my.data.co.uk/api/store/').success(function(data){
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