title: How to Set value of factory from controller?
body: <p>I created a <strong>factory</strong> below. 
  I want to set the value of <strong>page_id field</strong>.
  I use two function are <strong>setPageId</strong> and <strong>getPageId</strong> :</p>
  
  <pre><code>app.factory('socket', [function ($scope) {
          var onmessageDefer;
          var trustedClose = false;
          debugger;
          var url = 'ws://localhost:8084/javaSocketTest/socket';
          var page_id = '';
          var socket = {
              ws: new WebSocket(url),
              send: function (header, data) {
                  var object = {};
                  object["type"] = header;
                  object["data"] = data;
                  if (socket.ws.readyState === 1) {
                      socket.ws.send(object);
                      console.log('send data: ');
                      console.log(object);
                  } else {
  
                  }
              },
              setPageId:function(page){
                  page_id=page;
                  debugger;
              },
              getPageId:function(){
                  return page_id;
              }
      };
               return socket;
      }]);
  </code></pre>
  
  <p>And in my Controller, i call function <strong>setPageId</strong> but <strong>page_id</strong> always= ''. 
  So How to fix it. what am I wrong ??</p>
  
  <pre><code>app.controller('postCtrl', function ($scope, $uibModal, $timeout, $filter, ngTableParams, SweetAlert, PostServices,socket) {
  
          socket.setPageId('trung');
  
         });
  </code></pre>