문제가 있습니다. Angular.js를 사용하여 restaurant name
을 사용하여 표의 데이터를 필터링해야합니다. 검색 창이 있습니다. 사용자가 이름의 첫 글자를 입력하면 해당 글자와 관련된 모든 이름이 필터링됩니다. 그런 일은 일어나지 않습니다. 아래 코드를 설명하고 있습니다.Angular.js.and PHP를 사용하여 예상대로 기능이 작동하지 않습니다.
<div class="input-group" style="margin-bottom:10px; width:300px;">
<input class="form-control" placeholder="Type Restaurant Name" name="q" type="text" ng-model="searchProduct.rest_name">
</div>
<table class="table table-bordered table-striped table-hover" id="dataTable" >
<thead>
<tr>
<th>Sl. No</th>
<th>Restaurant Name</th>
</tr>
</thead>
<tbody id="detailsstockid">
<tr dir-paginate="cus in ($parent.labelResults=(listOfCustomerData | filter:searchProduct.rest_name:startsWith | orderBy:'rest_name')) | itemsPerPage:5 track by $index" current-page="currentPage">
<td>{{itemsPerPage *(currentPage-1)+$index+1}}</td>
<td>{{cus.rest_name}}</td>
</tr>
</tbody>
</table>
내 컨트롤러 사이드 코드는 아래와 같습니다. 여기
$http({
method:'GET',
url:"php/customerInfo.php?action=disp",
headers: { 'Content-Type': 'application/x-www-form-urlencoded' }
}).then(function successCallback(response){
console.log('res',response.data);
$scope.listOfCustomerData=response.data;
},function errorCallback(response) {
})
$scope.startsWith = function (actual, expected) {
var lowerStr = (actual + "").toLowerCase();
return lowerStr.indexOf(expected.toLowerCase()) === 0;
}
내가 같은 Anjum하는 & P 중국 음식 익스프레스, 예약자 BBQ &으로 많은 레스토랑 이름이 생각 게 판잣집, 백정과 베이커, 선인장 클럽 스티븐 애비뉴, 선인장 클럽 - 마크 셀로드 트레일. 여기에 사용자가 검색 창 안쪽에 타이핑을 할 때, 반드시 시작해야만하는 이름이 필터를 걸어야 만하지만 그렇게되지는 않습니다. 정적 값을 객체에 할당하는 경우 $scope.listOfCustomerData
이 기능은 예상대로 작동하지만 PHP.but를 사용하여 동적으로 데이터를 가져 오는 경우가 발생하지 않습니다. 도와주세요.
의이'angularjs.js을 던지는 당신을 따라함으로써 : 107 오류 : [$ 구문 분석 : 구문] http://errors.angularjs.org/1.4.6/$parse/syntax?p0=%7C&p1=not%20a%20primary...expression&p2=77&p3=(%24parent.labelResults%3D(listOfCustomerData%20%20) % 7CNaNilter % 3AstartsWith % 3A'rest_name '% 3A % 20 % 7C % orderBy % 3 A'rest_name ')) & p4 = % 7C % orderBy % 3A'rest_name'))'오류. – subhra
하지만 정적 데이터를'$ scope.listOfCustomerData'객체에 할당하면 내 코드도 작동하지만 DB에서 데이터를 가져옵니다. 그래서 exepected 당 작동하지 않습니다. – subhra
왜 $ parent.labelResults를 사용하고 있습니까? –