1.0.0 • Published 7 years ago

ng-consult-cep v1.0.0

Weekly downloads
3
License
MIT
Repository
github
Last release
7 years ago

ng-consult-cep

Angularjs service to consult CEP on correios

Small lib to consult CEP on Correios

DEMO https://codepen.io/douglaspinheiro/pen/bryEpq

npm install --save ng-consult-cep

Add this app as dependence in your app

angular.module('example', 'ngConsultCEP')

Inject service in your controller

angular.module('example').controller('mainCtrl', ['$scope', 'ConsultCEP', function($scope, ConsultCEP)

And call the function

ConsultCEP.get(cep).then(function(response) {
    var address = response.data;

    $scope.address = address.logradouro;
    $scope.neighborhood = address.bairro;
    $scope.city = address.localidade;
    $scope.state = address.uf;
    $scope.ibge = address.ibge;
});