Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

224
Views
search data with angular and php

I try when click it button search , router to page search and search data in php . Here is my code

html:

<input type="text"  placeholder="Search" ng-model="vm.search">
<button ui-sref="search?({item : vm.search})" class="btn btn-default"></button>

router

.state('search?',{
    url:'/search?/{item}',
templateUrl:'/saha/src/client/app/search/search.html',
controller:'searchController',
controllerAs:'vm',
resolve:{
searchItems : ['dataServices','$stateParams',function(dataServices,$stateParams) {
                return dataServices.searchItem($stateParams.item)
                                }]
                            }

                        })

controller

function searchController(logger,$stateParams,searchItems) {
                var vm = this;
                vm.data = searchItems;
                console.log(vm.data);

        }

services

 function searchItem(item) {
                        return $http({
                            method:'GET',
                            url: 'searchItem.php?item=' + item,
                            data : {
                                item: item
                            },
                            headers:{'Content-Type':'application/x-www-form-urlencoded'}
                        }).then(function(data) {
                            return data.data;


})
                }

And php

$row= array();
$item = isset($_GET['item']) ? trim($_GET['item']):'';
$sql  = "SELECT * FROM item WHERE tensp LIKE CONCAT('%',?,'%')";
if($stmt= $conn->prepare($sql)){
    $stmt->bind_param("s",$item);
    $stmt->execute();
$result = $stmt->get_result();
while($r = $result->fetch_array(MYSQLI_NUM)){
    $row[] =$r;

}
}
echo json_encode($row);

But i get empty array in controller . Where is my wrong? Please help me Here is in console i get enter image description here

over 4 years ago · Santiago Trujillo
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!