Posted By

ravinathdo on 09/19/17


Tagged

angularjs


Versions (?)

angularJS: get codeigniter json output


 / Published in: JavaScript
 

This code use for get data from php codeigniter controller via angulrJS on view

  1. <!--Angular http call-->
  2. <!--view-->
  3. $http({
  4. url: "getSubtype/1",
  5. method: "GET",
  6. }).then(function (response) {
  7. console.log('res');
  8. console.log(response.data);
  9. console.log(response.data.a);
  10. console.log(response.data.b);
  11. });
  12. <!--view-->
  13.  
  14. <!--controlelr-->
  15. public function getSubtype($cdsacc) {
  16. $arr = array('a' => 1, 'b' => 2, 'c' => 3, 'd' => 4, 'e' => 5);
  17. return $this->output
  18. ->set_content_type('application/json')
  19. ->set_status_header(200)
  20. ->set_output(json_encode(array(
  21. 'a' => '111',
  22. 'b' => '555'
  23. )));
  24. }
  25.  
  26. <!--controlelr-->
  27.  
  28. <!--//Angular http call-->

Report this snippet  

You need to login to post a comment.