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

Popular posts from this blog

javascript - Chart.js (Radar Chart) different scaleLineColor for each scaleLine -

apache - Error with PHP mail(): Multiple or malformed newlines found in additional_header -

java - Android – MapFragment overlay button shadow, just like MyLocation button -