使用AngularJS $ http显示来自Mysql数据库的特定学生记录

时间:2015-05-14 11:23:29

标签: javascript php mysql angularjs http

我在mysql数据库中有这个表

enter image description here

当学生在输入栏中输入他的rollno时,它应该显示他的记录。 enter image description here

我的代码

<div class="col-sm-3">

<input type="text" ng-model="filterTask" class="form-control search header-elements-margin" placeholder="Enter your rollno">

</div>
</div></div>
<div class="widget-body ">

<div class="task">
 <div ng-class="{strike:task.STATUS==2}" style="font-weight:bold;"><span>ID </span> <span> Name </span> <span> Class </span> <span> Father </span> <span> Teacher</span></div>
    <label class="checkbox" ng-repeat="task in tasks | filter : filterTask">

    <div ng-class="{strike:task.STATUS==2}"><span>{{task.id}} </span> <span> {{task.name}} </span> <span> {{task.class}} </span> <span> {{task.father}} </span> <span> {{task.teacher}}</span></div>

    </label>
</div>

<script>
    //Define an angular module for our app
var app = angular.module('myApp', []);

app.controller('studentController', function($scope, $http) {
  getTask(); // Load all available tasks 
  function getTask(){  
  $http.post("getStudents.php").success(function(data){
        $scope.tasks = data;
       });
  };
});
    </script>

它显示所有记录,但我需要在输入rollno时显示特定结果。它就像一个过滤器,但我想在输入他的rollno时得到具体的学生成绩。

0 个答案:

没有答案