How vskosp/vsgoogleautocomplete works
Project Type and Purpose
• This is a client-side AngularJS module (no server-side code).
• It provides two main directives:
– vs-google-autocomplete: wraps Google Places Autocomplete
– vs-autocomplete-validator: embedded validation of selected place
• It’s packaged via Bower/npm, built with Grunt, then published in the dist/ folder.
File Structure
Top-level files & folders:
• src/ – two source files (vs-google-autocomplete.js, vs-autocomplete-validator.js)
• dist/ – concatenated/minified bundles for distribution
• Gruntfile.js – build tasks (concat, uglify, versioning)
• bower.json, package.json – dependency/configuration manifests
• README.md – module usage and API documentation
No backend or database directories—this is purely a frontend library.
README for Insights
• Describes module features, directives, validation flows.
• Shows integration steps (add Google Maps script, include dist bundle, inject Angular module).
• Lists parsing directives, custom‐validator extension points.
a. AngularJS Host Application
– YourApp Module (injects vsGoogleAutocomplete)
– NgModelController (binds input → model)
b. vsGoogleAutocomplete Directive
– Attaches to an <input> element
– Listens to Google Autocomplete events
c. vsAutocompleteValidator Directive
– Wraps ngModelController.$validators
– Calls built-in/custom validator factories
d. vsGooglePlaceUtility Service
– Shared helper for parsing PlaceResult
e. Google Maps JavaScript API v3 (External Service)
– Provides Autocomplete and PlaceResult objects
f. Build/Distribution Pipeline (secondary layer)
– src/ → Grunt tasks (concat, lint, uglify) → dist/
– Bower/npm publishing
Relationships & Data Flow
• User types into <input> → vs-google-autocomplete intercepts and calls Google API.
• Google API returns PlaceResult → directive populates ngModel and fires parsing directives (= model components).
• vs-autocomplete-validator watches ngModel changes → invokes default + custom validator functions → updates $error state.
• Parsed address components travel back to Angular scope via bound attributes (vs-city, vs-street, etc.).
• Build pipeline has no runtime role but should be shown as a separate “Development” band.
Architectural Patterns & Principles
• Directive-Service-Factory pattern in AngularJS.
• Single Responsibility:
– One directive for autocomplete, one for validation.
– Utility service abstracts PlaceResult parsing.
• Extension Points: custom validator factories plug into the validation directive.
• Distribution separation: source vs built bundles.
Technologies & Frameworks to Call Out
• AngularJS 1.x (Modules, Directives, Services, Factories)
• Google Maps JavaScript API v3 (Places library)
• Grunt (build automation)
• Bower & npm (package management)