Last active
June 27, 2024 15:14
-
-
Save NickToye/5d90b6a6ef7aaa584f09 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
angular.module('store', ['ngRoute']) | |
.config(function($routeProvider){ | |
$routeProvider | |
.when('/', { | |
templateUrl: 'views/home.html' | |
}) | |
.when('/stores/', { | |
templateUrl: 'views/stores.html' | |
}) | |
.when('/stores/:id', { | |
controller: 'detailCtrl', | |
templateUrl: 'views/store.html' | |
}) | |
.when('/search/', { | |
templateUrl: 'views/search.html' | |
}) | |
.otherwise({ | |
redirectTo: '/' | |
}); | |
}) | |
.controller('appCtrl', function($scope, $http) { | |
$http.get('//api.uat.sofology.co.uk/api/store/').success(function(data,status,headers,config) { | |
$scope.stores = data; | |
}); | |
store.submit = function() { | |
$http.get('http://api.uat.sofology.co.uk/api/localstores/' + store.postcode).success(function(data){ | |
store.stores = data; | |
}); | |
}; | |
}) | |
.controller('detailCtrl', function($scope,$routeParams) { | |
$scope.store = $scope.stores.filter(function(store) { | |
return store.outlet == $routeParams.id | |
})[0]; | |
}) | |
.controller('searchCtrl', function($scope, $http) { | |
$http.get('http://api.uat.sofology.co.uk/api/search/?query=Akira::').success(function(data,status,headers,config) { | |
$scope.search = data; | |
}); | |
}) |
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
<form novalidate method='get' name="storesForm" id='searchForm' ng-submit="store.submit()"> | |
<label for="postcode" class="controls__label">Postcode</label> | |
<input required type="text" name="postcode" placeholder="Search..." ng-model="store.postcode"> | |
<input type="submit" value="Search"> | |
</form> | |
<article ng-repeat="store in stores" class="card"> | |
<address> | |
<h3 ng-if="store.outlet" class="title">{{store.outlet}}</h3> | |
<p ng-if="store.phone" class="tel">t. {{store.phone}}</p> | |
<p class="address1"><span ng-if="store.addressOne">{{store.addressOne}}, <br /></span> | |
<span ng-if="store.addressTwo">{{store.addressTwo}}, <br /> </span> | |
<span ng-if="store.addressThree">{{store.addressThree}}, <br /></span> | |
<span ng-if="store.town">{{store.town}}, <br /></span> | |
<span ng-if="store.county">{{store.county}}, <br /></span> | |
<span ng-if="store.postCode">{{store.postCode}}</span> | |
</p> | |
<a class="btn btn--primary" ng-href="#/stores/{{store.outlet}}">View Store</a> | |
</address> | |
</article> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment