title: angular.js routing and stateparams
body: <p>I'm trying to modify standard user module of meanjs. I added a simple route:</p>
  
  <pre><code>state('users', {
              url: '/users/:username',
              templateUrl: 'modules/users/views/view-profile.client.view.html'
          });
  </code></pre>
  
  <p>And in my view:</p>
  
  <pre><code>data-ng-controller="ViewProfileController" data-ng-init="findUser()"
  </code></pre>
  
  <p>I also injected $stateParams to my controller. So in my <code>ViewProfileController</code> - <code>findUser</code> function, when I write this:</p>
  
  <pre><code>console.log($stateParams.username)
  </code></pre>
  
  <p>I expect to get username parameter. But it returns <code>undefined</code>.</p>
  
  <p>When I set the route this way, </p>
  
  <pre><code>state('users', {
              url: '/users/:username',
              template: function ($stateParams){
                  return $stateParams.username;
              }
          });
  </code></pre>
  
  <p>it returns username. I don't know what is wrong or missing. Any ideas?</p>
  
  <p>edit: this was my full controller code</p>
  
  <pre><code>'use strict';
  
  angular.module('users').controller('ViewProfileController', ['$scope', '$http', '$stateParams', '$location', 'Users', 'Authentication', 
  function($scope, $http, $location, Users, Authentication, $stateParams) {
      $scope.user = Authentication.user;
  
  
      $scope.findUser = function () {
          console.log($stateParams);
          ...
      };
  }
  ]);
  </code></pre>