Its very easy. The AngularJS beginners  might be curious on this. $scope is also an object. So $scope variables represents key value pairs of Javascript object. Here I have given one simple example to show to do this

For $scope variables

$scope.val1 = "object value 1";
$scope.val2 = "object value 2";

$scope['val1'] // gives 'object value 1'
$scope['val2'] // gives 'object value 2'

For JavaScript variables 

We can use eval to find local JavaScript variables within a function
var jsvar = "object variable";
eval('jsvar') // gives 'object variable'

For JavaScript Global Variables

Here it is JavaScript global variables. these are part of window object.
var globalJsvar = "global variable";
function myCtrl($scope) {
  window['globalJsvar'] // gives 'global variable'



Popular Posts