etodanik / ion-google-place

Ionic directive for a location dropdown that utilizes google maps
MIT License
251 stars 201 forks source link

Multiple fields #39

Open moretty opened 9 years ago

moretty commented 9 years ago

It's not running as expected when you have two fields. It would be nice if you add support for multiple fields on the same view. Actually when you click the second element, it opens the same result view of the other ion-google-place element.

Is it in your development plants?

moretty commented 9 years ago

Sorry, I finally read all the pull requests and found the answer.

You just need to add the "scope" part in to the main .js like this:

template: '<input type="text" readonly="readonly" class="ion-google-place" autocomplete="off">',
                replace: true,
                scope: {
                    ngModel: '=?'
                },

and after that, you can implement multiple selectors changing the paramenter "ng-model" in the ion-google-place doom element!

: ) Sorry for the inconveniences. I expect that my comment help other people find it quicker!

hfcipriano commented 8 years ago

OHH GOD. YOU SAVED ME

hfcipriano commented 8 years ago

Really helped me. You are a great man

cadrogui commented 7 years ago

@moretty thanks dude!

seatechdev commented 7 years ago

Can someone please post sample code? This is what I am doing in my controller.

$scope.toaddress = { location: '' };

$scope.$watch('toadrress.location', function(mynewVal, myoldVal) { if (mynewVal.hasOwnProperty('formatted_address')) {
var toaddressname = $scope.toadrress.location.name; }
});

$scope.fromddress = { location: '' };

$scope.$watch('fromadrress.location', function(newVal, oldVal) { if (newVal.hasOwnProperty('formatted_address')) {
var fromaddressname = $scope.fromadrress.location.name; }
});