title: How to pass string at the end of scope
body: <p>I am trying to dynamically alter what I access from a Json file using string at the end of my $scope call. </p>
  
  <pre><code> app.controller('dashboardCtrl', 
    ['$scope', '$rootScope', '$location', 'UserService',
      function($scope, $rootScope, $location, UserService) {
  
        var username = $rootScope.username;
  
        UserService.getUsers().success(function(data) {
          $scope.users = data
          $scope.loggedInUser = $scope.users.username
        })
  </code></pre>
  
  <p>So I am trying to pass the var username at the end of the last line, instead of $scope.users.<em>username</em>. At the moment it just searches for a JSON object "username" instead of the actual string held in username.</p>
  
  <p>This would mean I can search my JSON file for the logged in user depending on the rootScope variable that is username. </p>
  
  <p>Any help is greatly appreciated.</p>