angularjs - binding an expression into ng-src directive -


i trying load google map api link inside ng-src directive using method..

<script ng-src="{{trustsrc(vcustom.googlemapapi.src)}}"></script>

in controller have..

v.googlemapapi = { src: "https://maps.googleapis.com/maps/api/js?key=" + config.googleapikey + "&libraries=places" };  $scope.trustsrc = function (src) {         return $sce.trustasresourceurl(src);     } 

sometimes works , times doesn't.. error

referenceerror: google not defined...

i have tried different ways bind inside ng-src directive no success..

it works when add script <script src="https://maps.googleapis.com/maps/api/js?key=your_api_key&callback=initmap"></script> doesn't work dynamically.. ??

there no syntax error , controller ng-controller="custom vcustom"

any suggestions bind in ng-src directive ?

i think trying lazy load script. pls have @ below post may help. how asyncronously load google map in angularjs?


Comments