javascript - How to pass the variables to AngularJs config -
i work angularjs google maps , need configure api_key
in module config
part (question similar this one).
my question configuring angularjs modules
this my test pen:
var app = angular.module('myapp', []) /* // here ????? // try pass value html (server side) .config(function($window){ console.log($window.memkey); }) */ .controller('mainctrl', ['$scope', '$window', function($scope, $window) { $scope.name = $window.memname; $scope.city = $window.memcity; $scope.getmember = function(id) { console.log(id); }; }]);
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.23/angular.min.js"></script> <script type="text/javascript"> var memkey = 'bb7de28f-0f89-4f14-8575-d494203acec7'; var memname = 'john'; var memcity = 'new-york'; </script> <div ng-app="myapp" ng-controller="mainctrl"> member name: {{name}} <br> member city: {{city}} </div>
how possible recuperate memkey
value html (server) side?
your memkey in accesible scope, according on how you've declared it.
just do
app.config(function(){ console.log(memkey); })
see snippet
Comments
Post a Comment