<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.8/jquery.min.js"></script>
<script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=true&libraries=places&language=en-US"></script>
<script src="//ajax.googleapis.com/ajax/libs/angularjs/1.0.3/angular.min.js"></script>
<script src="//ajax.googleapis.com/ajax/libs/angularjs/1.0.3/angular-resource.min.js"></script>
angular.module('Otd', ['OtdDirectives']);
function SearchForm($scope){
$scope.doSearch = function(){
if($scope.location === ''){
alert('Directive did not update the location property in parent controller.');
alert('Yay. Location: ' + $scope.location);
angular.module('OtdDirectives', []).
directive('googlePlaces', function(){
template: '<input id="google_places_ac" name="google_places_ac" type="text" class="input-block-level"/>',
link: function($scope, elm, attrs, ctrl){
var autocomplete = new google.maps.places.Autocomplete($("#google_places_ac")[0], {});
google.maps.event.addListener(autocomplete, 'place_changed', function() {
var place = autocomplete.getPlace();
var location = place.geometry.location.lat() + ',' + place.geometry.location.lng();
$scope.$apply(function() {
$scope.location = location;
<div ng-app="Otd" ng-controller="SearchForm">
<google-places location="location"></google-places>
<button ng-click="doSearch()" class="btn btn-large btn-primary">Search</button>