SHOW:
|
|
- or go back to the newest paste.
| 1 | var am = angular.module('bp3-zip', []);
| |
| 2 | ||
| 3 | am.config(['$stateProvider', $stateProvider => {
| |
| 4 | - | $stateProvider. |
| 4 | + | $stateProvider. |
| 5 | state('zip-code', {
| |
| 6 | - | url: '/zip-code', |
| 6 | + | url: '/zip-code', |
| 7 | - | controller: 'ZipCodeCtrl', |
| 7 | + | controller: 'ZipCodeCtrl', |
| 8 | - | templateUrl: 'feature/bp3/zip-code.html' |
| 8 | + | templateUrl: 'feature/bp3/zip-code.html' |
| 9 | }); | |
| 10 | }]); | |
| 11 | ||
| 12 | - | am.factory('zipCodeSvc', ['$http', '$q', '$state', 'rest',
|
| 12 | + | am.factory('zipCodeSvc', ['$http', '$q', '$state', 'rest', ($http, $q, $state, rest) => {
|
| 13 | - | ($http, $q, $state, rest) => {
|
| 13 | + | var svc = {};
|
| 14 | - | var svc = {}
|
| 14 | + | |
| 15 | svc.searchByZip = (zipCode) => | |
| 16 | $http.post(rest.getRestUrlPrefix() + 'path/to/zipCode/service', zipCode); | |
| 17 | ||
| 18 | - | $http.post(rest.getRestUrlPrefix() + 'path/to/zipCode/service', zipCode); |
| 18 | + | |
| 19 | ]); | |
| 20 | ||
| 21 | am.controller('ZipCodeCtrl', ['$q', '$scope', 'zipCodeSvc', ($q, $scope, zipCodeSvc)
| |
| 22 | ||
| 23 | - | zipCodeSvc.searchByZip($scope.zipCode). |
| 23 | + | $scope.searchByZipCode = () == > {
|
| 24 | - | success(function (data) {
|
| 24 | + | zipCodeSvc.searchByZip($scope.zipCode). |
| 25 | - | //data will hold the result |
| 25 | + | success(function(data) {
|
| 26 | //data will hold the result | |
| 27 | - | }). |
| 27 | + | |
| 28 | - | error(function (error) {
|
| 28 | + | }). |
| 29 | - | console.log('Error retrieving data: ' + error);
|
| 29 | + | error(function(error) {
|
| 30 | - | }); |
| 30 | + | console.log('Error retrieving data: ' + error);
|
| 31 | }); | |
| 32 | }; | |
| 33 | ]); |