javascript - How to use AngularJS's scope values to generate custom html tag's attribute -
I'm trying to embed a Google Map's IFFR for my project, the problem of a per restaurant is that if The value of the address is in:
$ scope.restaurant.address and I must include this code:
& Lt; Iframe width = "450" height = "250" src = "https://www.google.com/maps/embed/v1/place?key=MY_KEY&q= {{restaurant.address}}" & gt; ; & Lt; / Iframe & gt; {{Restaurant.address}} has not been properly interpreted, and when {a link is generated instead of the appropriate address} {{restaurant.address}} appears. Any clues? Any help would be appreciated, thanks in advance!
Try something like this:
applications. Controller 'SomeController', function ($ scope, $ sce) {$ scope.restaurant.address = '1313 Mockingbird Ln.'; $ Scope.url = $ sce.trustAsResourceUrl ("https: //Www.google.com/maps/ Embed / v1 / place? Key = MY_KEY & amp; q = "+ $ scope.restaurant.address);}); HTML: & lt; Iframe width = "450" height = "250" ng- src = "{{url}}" & gt; & Lt; / Iframe & gt; You can read more about ngSrc here: $ sce is a service that Toughly referenced services to AngularJS $ Sce
Comments
Post a Comment