title: ZF3: How to response a JSON from an action function
body: <p>I'm calling to an action function using angular js. I call the action function and receive the parameters correctly, but when I try to response a JsonModel I don't know why Zend Framework responde with a ViewModel. I think because Zend Framework doesn't detect an Ajax call from Angular JS. So, how can a I call to my action function and Zend Framework detects this call like an Ajax call?</p>
  
  <p><strong>angular js:</strong></p>
  
  <pre><code>self.sendData = function(url, data){
      var promise = $q.defer();
      console.log("Dentro de senDAta!!!");
      var config = {
          headers : {
              "Accept"        :   "application\json",
              "Content-Type"  :   "application\json"
          },
          resposeType : "json"
      };
      $http.post(url, data, config).success(function(response, status, headers, config){
                  console.log("dentro de success!!!");
                  promise.resolve(response);
              }).error(function(data){
                  //Error de sistemas
                  console.log("Error en sendData: " + data);
              });
      return promise.promise;        
  };  
  </code></pre>
  
  <p><strong>/application/config/module.config.php</strong></p>
  
  <pre><code>return [
      //...
  
      'view_manager' =&gt; [
          //...
  
          'strategies' =&gt; [
              'ViewJsonStrategy',
          ],
      ],
  ];
  </code></pre>
  
  <p><strong>/Controller/LoginController.php</strong></p>
  
  <pre><code>public function loginAction(){
      $request = $this-&gt;getRequest();
      $log = new \File\LogWriter();
      $log-&gt;writeLog(get_class($this) . "::" . __FUNCTION__ . ": Dentro de loginAction()");
      if ($this-&gt;getRequest()-&gt;isXmlHttpRequest() === true){
          $log-&gt;writeLog(get_class($this) . "::" . __FUNCTION__ . ": Llamada hecha por Ajax");
      }else{
          $log-&gt;writeLog(get_class($this) . "::" . __FUNCTION__ . ": Llamada no hecha por ajax");
      }
          $params = json_decode(file_get_contents('php://input'),true);
          $email = $params["email"];
          $password = $params["password"];
  
          $log-&gt;writeLog(get_class($this) . "::" . __FUNCTION__ . ": email: " . $email . " password: " . $password);
          $user = new User($email);
          return new JsonModel([
              "result"    =&gt; 0
          ]);             
  }
  </code></pre>