title: trying to display name angular
body: <p>I'm still trying to learn <strong>angular JS</strong> and I am having trouble displaying the user I've just entered into the database to display on the next partial. I am able to display the other users but the data returned to me just after the user added just won't come out! I've learned a lot of ways to get it wrong, can someone show me how to do it right?
  here's my code.</p>
  
  <p>Initial splash page</p>
  
  <pre><code>&lt;div ng-controller="usersController"&gt;
  &lt;h1&gt;Hello!&lt;/h1&gt;
  &lt;h1&gt;Please enter your name to join and share your ideas&lt;/h1&gt;
  &lt;form&gt;
      &lt;input type="text" ng-model="newUser.name"&gt;
      &lt;button ng-click="addUser()"&gt;Enter&lt;/button&gt;
  &lt;/form&gt;
  </code></pre>
  
  <p></p>
  
  <p>angular routes</p>
  
  <pre><code>var myApp = angular.module('myApp', ['ngRoute']);
  myApp.config(function ($routeProvider) {
      $routeProvider
      .when('/', {
          templateUrl: '../partials/main.html'
      })
      .when('/dashboard', {
          templateUrl: '../partials/dashboard.html' 
      })
      .otherwise({
          redirectTo: '/'
      });
  });
  </code></pre>
  
  <p>the page I want to display the current user and all users added</p>
  
  <pre><code>&lt;div ng-controller="usersController"&gt;
  &lt;h1&gt;Welcome&lt;/h1&gt;
  &lt;h1 ng-bind="currentUser.name"&gt;&lt;/h1&gt;
  &lt;ul ng-repeat="user in allUsers"&gt;
      &lt;li ng-bind="user.name"&gt;&lt;/li&gt;
  &lt;/ul&gt;
  </code></pre>
  
  <p></p>
  
  <p>my users controller</p>
  
  <pre><code>myApp.controller('usersController', function ($scope, usersFactory) {
  
  var getUsers = function() {
      usersFactory.getUsers(function (data) {
          $scope.allUsers = data;
      })
  }
  
  $scope.addUser = function () {
      usersFactory.addUser($scope.newUser, function (data) {
          $scope.currentUser = {'name': data.name};
      })
  }
  
  getUsers();
  })
  </code></pre>
  
  <p>my users factory</p>
  
  <pre><code>myApp.factory('usersFactory', function ($http, $location) {
  
  var factory = {};
  
  factory.getUsers = function (callback) {
          $http.get('/show_users').success(function (users) {
              callback(users);
          })
      }
  
  factory.addUser = function (data, callback) {
      $http.post('/new_user', data).success(function (user) {
          callback(user);
          $location.path('/dashboard');
      })
  }       
  return factory;
  })
  </code></pre>
  
  <p>any help is much appreciated!</p>