W
W
westdp2016-08-10 20:07:20
Angular
westdp, 2016-08-10 20:07:20

How to write data from a directive?

I use a plugin to search for an address using https://github.com/kuhnza/angular-google-places-au... , this plugin implements an output to the page with a json filter {{place | json}}
. A piece of HTML:

div.container(ng-controller="googleAddressCtrl")
  //div(id="map")
  ul.select
    li
      div.input-container
        input(type="text", g-places-autocomplete, ng-model="place", class="input-container__simple", placeholder="{{langa.TypeYourAddress}}")
    p {{place | json}}

Tell me how to display this data, for example, in $scope.NewPlace
At the output, now we get:
<p class="ng-binding">{
  "address_components": [
    {
      "long_name": "",
      "short_name": "UA",
      "types": [
        "country",
        "political"
      ]
    },
    {
      "long_name": "Деснянский район",
      "short_name": "Деснянский район",
      "types": [
        "sublocality_level_1",
        "sublocality",
        "political"
      ]
    },
    {
      "long_name": "Киев",
      "short_name": "Киев",
      "types": [
        "locality",
        "political"
      ]
    },
    {
      "long_name": "город Киев",
      "short_name": "город Киев",
      "types": [
        "administrative_area_level_2",
        "political"
      ]
    },
    {
      "long_name": "город Киев",
      "short_name": "город Киев",
      "types": [
        "administrative_area_level_1",
        "political"
      ]
    }
  ],
  "adr_address": "",
  "formatted_address": "Ukraine",
  "geometry": {
    "location": {
      "lat": 50.495313,
      "lng": 30.557908999999995
    }
  },
  "icon": "https://maps.gstatic.com/mapfiles/place_api/icons/bus-71.png",
  "id": "225307284ab14beacae1bea284523a242e9ec33d",
  "name": "SkyMall",
  "photos": [
    {
      "height": 1836,
      "html_attributions": [
        "&lt;a href=\"https://maps.google.com/maps/contrib/117418578841312508464/photos\"&gt;Rostyslav Kravets&lt;/a&gt;"
      ],
      "width": 3264
    }
  ],
  "place_id": "ChIJnw18gsHR1EARuRMibcGf0W8",
  "reference": "CmRaAAAAnptOnjou1oe-gfE1gKjKNuoIHlgfQpKGUERMS7FWGVtCVfBzfII4ktvLOa6ONac27YCdb1xHwXOg0kPr2uiXotdxSRNSmrn7eUj05Mlzu3AWNIp42iBQLbq9Bvj4WiqtEhCQwJfzg0xF9VJp90XyPEBvGhTWm3nM99Isn64L-m1FYnxsysBoYQ",
  "scope": "GOOGLE",
  "types": [
    "bus_station",
    "transit_station",
    "point_of_interest",
    "establishment"
  ],
  "url": "https://maps.google.com/?cid=8057396861450982329",
  "utc_offset": 180,
  "vicinity": "Ukraine",
  "html_attributions": []
}</p>

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question