Comments (1)
Hi @Aathi
First Question
I have found three ways to get the full address:
- If you only want to display the full address you can fetch the
adr_address
attribute from theplace
object you receive in the callback function and print the value using{{{ }}}
in your template. - If you have a variable bound to the ember-autocomplete field, that attribute will have the complete address after Google autocomplete fill the field. (the variable you pass in the
value
option). - The other option is fetch the
adr_address
attribute and remove the HTML part of the string
CONTROLLER
export default Ember.Controller.extend({
fullAddress: null,
actions:{
done: function(){
Ember.$('#message').fadeOut(500, () => {
this.set('message', 'Focus out');
}).fadeIn(500);
},
placeChanged: function(place){
this.set('placeJSON', JSON.stringify(place, undefined, 2));
if (place.adr_address) {
let regexp = /(<span(?: \w+="[^"]+")*(?: \w+="[^"]+")*>([^<]*)<\/span>)/g,
fullAddress = place.adr_address.replace(regexp, "$2");
this.set('cleanFullAddress', fullAddress);
}
this.set('fullAddress', place.adr_address);
},
placeChangedSecondInput: function(place){
this.set('placeJSONSecondInput', JSON.stringify(place, undefined, 2));
}
}
});
TEMPLATE
<p id="message">Message: {{message}}</p>
<p>Full adddress from JSON sent to the callback: {{{fullAddress}}}</p>
<p>Clean string: {{cleanFullAddress}}</p>
<p> Model address: {{model.address}}</p>
<div class="test-place-autocomplete-container">
{{place-autocomplete-field
value= model.address
handlerController= this
inputClass= 'place-autocomplete--input'
focusOutCallback="done"
placeChangedCallback="placeChanged"
}}
</div>
<pre style="font-size: 6px;">
{{placeJSON}}
</pre>
<h2>Automcomplete 2</h2>
<div class="test-place-autocomplete-container">
{{place-autocomplete-field
value= model.address2
handlerController= this
inputClass= 'place-autocomplete--input-2'
inputId='place-autocomplete--input-2'
placeChangedCallback="placeChangedSecondInput"
types='(cities)'
restrictions=restrictions
}}
</div>
<pre style="font-size: 6px;">
{{placeJSONSecondInput}}
</pre>
{{outlet}}
Second question
It was not implemented, but I just create a branch with that option and we will merge it soon.
If you have any question or this was not useful feel free to reply and I will be glad to answer again,
Daniel.
from ember-place-autocomplete.
Related Issues (20)
- Multiple input destroy issue HOT 4
- Use Qunit instead of Mocha
- DOC: Update tests support section wording and examples code.
- New release (2.1.3?) HOT 3
- Application initializes before Google Places library loads HOT 1
- Assertion Failed: Cannot call set with 'address' on an undefined object. HOT 1
- put an example that actually works HOT 6
- Can creation of script tag be deferred until page load? HOT 4
- After update ember 3.1.2, inputClass doesn't appear HOT 3
- new release? HOT 4
- Fix Acceptance Tests instructions in Readme HOT 1
- Support for session token HOT 8
- Deprecation on latest Ember HOT 3
- placeChangedCallback and focusOutCallback actions not being called HOT 3
- Issue with using inside component HOT 5
- Latitude and Longitude on City HOT 5
- (Just a question) Is there a way to customize the pac container if you are using it multiple places? HOT 1
- autocomplete not working inside component template HOT 1
- Cannot read property 'getPlacePredictions' HOT 6
- Test Mocks are not usable by consumers HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from ember-place-autocomplete.