Last active
June 27, 2024 15:16
-
-
Save NickToye/ab7b004d2c3889174417 to your computer and use it in GitHub Desktop.
This file contains 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"; | |
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