typescript - Connect to Google Cloud Endpoints from an Angular 2 app -
i refactoring web-app angular 1 angular 2, having difficulties finding examples connecting google cloud endpoints angular 2 app.
i used angular-cli create angular 2 application. want use endpoints api couple of different services, preferable if suggested answer takes account.
in angular 1 did following
in index.html:
<script> function init() { console.log("initializing cloud endpoints.."); window.init(); }; </script> <script src="https://apis.google.com/js/client.js?onload=init"></script> and in main.js:
function main($scope, $window){ var vm = this; $window.init= function() { $scope.$apply(vm.loadapi); }; vm.loadapi = function(){ gapi.client.load('devicestockapi', 'v1', function(){ console.log("cloud endpoints available"); }, 'https://name-of-my-endpoints-app.appspot.com/_ah/api'); } } in angular 2 have tried
edit1: should note trying api load starters. why have put code in index.html file in example below. however, optimally, prefer solution best practice initiating , using cloud endpoints angular 2 app.
in index.html:
<script src="https://apis.google.com/js/client.js?onload=init"></script> <script> function init() { console.log("init called"); gapi.client.load('devicestockapi', 'v1', function(){ console.log("cloud endpoints available"); }, 'https://name-of-my-endpoints-app.appspot.com/_ah/api'); } </script> when run webapp, init function not called (no console output). however, seems script loaded.
any suggestions how fix appreciated! also, if has found documentation google or others elaborating on this, please share!
have tried reversing order of operations here? did angular 1, try moving apis.google.com import below init codeblock.

Comments
Post a Comment