如何在 google 处使用函数添加 google api 键和回调函数 api

how to add google api key and callback function using a function in google places api

我想从 angularjs 文件发送我的 google api 密钥和回调,而不是 google 位置的 URL api。但我不知道该怎么做。 请告诉我如何使用另一个文件中的 angularjs 来执行此操作,而不是在同一个 HTML 文件中。基本上,我想添加 google 地方 api 所需的所有功能,例如 initAutocomplete、fillinaddress 和使用 angularjs 以及我的 api 键从另一个文件进行地理定位。

目前,我是

<script src="https://maps.googleapis.com/maps/api/js?key==APIKEY&libraries=places&callback=initAutocomplete"
async defer></script>

但我不想在此处使用 api 密钥和 initAutocomplete

经过大量搜索我找到了解决方案

Here is my solution to add api key or script using function

 $scope.loadScript = function() {
    var script = document.createElement('script');
    script.type = 'text/javascript';
    script.src = 'https://maps.google.com/maps/api/js? 
 sensor=false&callback=initialize';
    document.body.appendChild(script);
    setTimeout(function() {
        $scope.initialize();
    }, 500);
 }

And for google places library functions I have created an angularjs directive.