@incdevco/framework
Version:
node.js lambda framework
320 lines (302 loc) • 6.5 kB
JavaScript
/* global angular */
angular.module('address', [])
.directive('addressRead', [
function () {
return {
replace: true,
restrict: 'E',
scope: {
address: '='
},
templateUrl: 'address/templates/read-directive.html'
};
}
])
.directive('addressWrite', [
'AddressService',
function (AddressService) {
return {
link: function ($scope) {
$scope.countries = AddressService.countries();
$scope.states = AddressService.states();
},
replace: true,
restrict: 'E',
scope: {
address: '='
},
templateUrl: 'address/templates/write-directive.html'
};
}
])
.factory('AddressService', [
function () {
return {
countries: () => {
return [
{
iso_2_code: 'US',
iso_3_code: 'USA',
iso_num_code: 840,
name: 'United States'
}
];
},
new: () => {
return {
city: null,
country: {
iso_2_code: 'US',
iso_3_code: 'USA',
iso_num_code: 840,
name: 'United States'
},
postal_code: null,
state: null,
street: null,
unit: null
};
},
states: () => {
return [
{
abbreviation:'AL',
name:'Alabama'
},
{
abbreviation:'AK',
name:'Alaska'
},
{
abbreviation:'AZ',
name:'Arizona'
},
{
abbreviation:'AR',
name:'Arkansas'
},
{
abbreviation:'CA',
name:'California'
},
{
abbreviation:'CO',
name:'Colorado'
},
{
abbreviation:'CT',
name:'Connecticut'
},
{
abbreviation:'DE',
name:'Delaware'
},
{
abbreviation:'FL',
name:'Florida'
},
{
abbreviation:'GA',
name:'Georgia'
},
{
abbreviation:'HI',
name:'Hawaii'
},
{
abbreviation:'ID',
name:'Idaho'
},
{
abbreviation:'IL',
name:'Illinois'
},
{
abbreviation:'IN',
name:'Indiana'
},
{
abbreviation:'IA',
name:'Iowa'
},
{
abbreviation:'KS',
name:'Kansas'
},
{
abbreviation:'KY',
name:'Kentucky'
},
{
abbreviation:'LA',
name:'Louisiana'
},
{
abbreviation:'ME',
name:'Maine'
},
{
abbreviation:'MD',
name:'Maryland'
},
{
abbreviation:'MA',
name:'Massachusetts'
},
{
abbreviation:'MI',
name:'Michigan'
},
{
abbreviation:'MN',
name:'Minnesota'
},
{
abbreviation:'MS',
name:'Mississippi'
},
{
abbreviation:'MO',
name:'Missouri'
},
{
abbreviation:'MT',
name:'Montana'
},
{
abbreviation:'NE',
name:'Nebraska'
},
{
abbreviation:'NV',
name:'Nevada'
},
{
abbreviation:'NH',
name:'New Hampshire'
},
{
abbreviation:'NJ',
name:'New Jersey'
},
{
abbreviation:'NM',
name:'New Mexico'
},
{
abbreviation:'NY',
name:'New York'
},
{
abbreviation:'NC',
name:'North Carolina'
},
{
abbreviation:'ND',
name:'North Dakota'
},
{
abbreviation:'OH',
name:'Ohio'
},
{
abbreviation:'OK',
name:'Oklahoma'
},
{
abbreviation:'OR',
name:'Oregon'
},
{
abbreviation:'PA',
name:'Pennsylvania'
},
{
abbreviation:'RI',
name:'Rhode Island'
},
{
abbreviation:'SC',
name:'South Carolina'
},
{
abbreviation:'SD',
name:'South Dakota'
},
{
abbreviation:'TN',
name:'Tennesee'
},
{
abbreviation:'TX',
name:'Texas'
},
{
abbreviation:'UT',
name:'Utah'
},
{
abbreviation:'VT',
name:'Vermont'
},
{
abbreviation:'VA',
name:'Virginia'
},
{
abbreviation:'WA',
name:'Washington'
},
{
abbreviation:'WV',
name:'West Virginia'
},
{
abbreviation:'WI',
name:'Wisconsin'
},
{
abbreviation:'WY',
name:'Wyoming'
},
{
abbreviation:'AS',
name:'American Somoa'
},
{
abbreviation:'DC',
name:'District of Columbia'
},
{
abbreviation:'FM',
name:'Federated States of Micronesia'
},
{
abbreviation:'GU',
name:'Guam'
},
{
abbreviation:'MH',
name:'Marshall Island'
},
{
abbreviation:'MP',
name:'Northern Mariana Islands'
},
{
abbreviation:'PW',
name:'Palau'
},
{
abbreviation:'PR',
name:'Puerto Rico'
},
{
abbreviation:'VI',
name:'Virgin Islands'
}
];
}
};
}
]);