我的问题:在我从angularjs文件和Controller文件执行查询后,我无法显示我想要的数据。 这是我的Angularjs文件:
$scope.confirmCapnhat=function(p_id,dn_ngayLap){
if($scope.p_id!="" && $scope.dn_ngayLap!="")
{
var thang=dn_ngayLap.getMonth();
var Nam=dn_ngayLap.getFullYear();
if(thang>9)
var NamThang=Nam+"-"+thang;
else
var NamThang=Nam+"-0"+thang;
$http.get(API+'diennuoc/'+p_id+'/'+NamThang+'/capnhat').then(successCallback,errorCallback);
function successCallback(response){
// $scope.name = "John Doe";
console.log(response);
$scope.diennuoc=response.data;
};
function errorCallback(response){
$scope.sodauDien=0;
$scope.sodauNuoc=0;
};
}
else
alert('Chưa chọn phòng hoặc ngày lập!');
}
在我的路线文件(web.php)中,我定义为:Route::get('diennuoc/{p_id}/{dn_ngayLap}/capnhat','DienNuocController@capnhat');
以下是我的Controller文件:
public function capnhat($p_id,$dn_ngayLap)
{
$sql="select * from diennuoc where p_id='".$p_id."' and dn_ngayLap='".$dn_ngayLap."'";
$diennuoc=DB::select($sql);
return $diennuoc;
}
当我在Blade.php源代码中运行它时,我点击源中间的一个按钮(ng-click =“confirmCapnhat(p_id,dn_ngayLap)”)。它不显示下面的数据。 我的Blade.php:
<div class="box box-default" ng-controller="DienNuocController">
<div class="box-header with-border">
<h3 class="box-title">Thêm điện nước</h3>
<div class="box-tools pull-right">
<button type="button" class="btn btn-box-tool" data-widget="collapse"><i class="fa fa-minus"></i></button>
</div>
</div>
<form class="form-horizontal" name="frmdiennuoc" method="POST" action="{{route('diennuoc.store')}}">
{{csrf_field()}}
<!-- /.box-header -->
<div class="box-body">
<div class="row">
<div class="box-body">
<div class="form-group">
<label for="inputPassword3" class="col-sm-2 control-label">Ngày lập:</label>
<div class="col-sm-10">
<div class="input-group date">
<div class="input-group-addon"><i class="fa fa-calendar"></i></div>
<input type="month" class="form-control" name="dn_ngayLap" value="{{old('dn_ngayLap')}}" ng-model="dn_ngayLap" />
</div>
</div>
</div>
<% dn_ngayLap %>
<div class="form-group">
<label for="inputEmail3" class="col-sm-2 control-label">Phòng:</label>
<div class="col-sm-10">
<select name="p_id" id="p_id" ng-model="p_id">
@foreach($dsphong as $phong)
<option value="{{$phong->p_id}}">{{$phong->p_ten}}</option>
@endforeach
</select>
</div>
</div>
<div class="form-group" ng-hide="myVar">
<label for="inputEmail3" class="col-sm-2 control-label"></label>
<div class="col-sm-10">
<input type="button" class="btn btn-primary" value="Cập nhật tháng trước" ng-click="confirmCapnhat(p_id,dn_ngayLap)" >
</div>
</div>
<div class="form-group">
<label for="inputEmail3" class="col-sm-2 control-label"><i class="fa fa-fw fa-eyedropper"></i></label>
<div class="col-sm-10">
<label for="inputEmail3" class="col-sm-2 control-label"><i class="fa fa-fw fa-bolt"></i>Điện</label>
</div>
</div>
<div class="form-group">
<label for="inputEmail3" class="col-sm-2 control-label">Chỉ số đầu:</label>
<div class="col-sm-10">
<input type="text" name="dn_sodauDien" class="form-control" id="dn_sodauDien" value="<% diennuoc.dn_socuoiDien %>">
</div>
</div>
<div class="form-group">
<label for="inputEmail3" class="col-sm-2 control-label"><i class="add-on icon-tint"></i>Chỉ số cuối:</label>
<div class="col-sm-10">
<input type="text" name="dn_socuoiDien" class="form-control" id="dn_socuoiDien">
</div>
</div>
<div class="form-group">
<label for="inputEmail3" class="col-sm-2 control-label"><i class="fa fa-fw fa-eyedropper"></i></label>
<div class="col-sm-10">
<label for="inputEmail3" class="col-sm-2 control-label"><i class="fa fa-fw fa-flask"></i>Nước</label>
</div>
</div>
<div class="form-group">
<label for="inputEmail3" class="col-sm-2 control-label">Chỉ số đầu:</label>
<div class="col-sm-10">
<input type="text" name="dn_sodauNuoc" class="form-control" id="dn_sodauNuoc" value="<% diennuoc.dn_socuoiNuoc %>" >
</div>
</div>
<div class="form-group">
<label for="inputEmail3" class="col-sm-2 control-label"><i class="add-on icon-tint"></i>Chỉ số cuối:</label>
<div class="col-sm-10">
<input type="text" name="dn_socuoiNuoc" class="form-control" id="dn_socuoiNuoc" value="{{old('dn_socuoiNuoc')}}"
>
</div>
</div>
</div>
<!-- /.form-group -->
<!-- /.col -->
<!-- /.box-body -->
<div class="box-footer">
<button type="submit" name="submit" class="btn btn-info pull-right" data-toggle="modal" data-target="#modal-info">
Thêm
</button>
</div>
<!-- /.box-footer -->
</form>
<!-- /.box-body -->
</div>
如果每次我得到照片,我怎么能得到: enter image description here