Angularjs 我只想在angular js中的一些操作上加载一个特定的div
我只想在angular js中的一些操作上加载一个特定的divAngularjs 我只想在angular js中的一些操作上加载一个特定的div,angularjs,Angularjs,我只想在angular js中的一些操作上加载一个特定的div <div class="row"> <div class="col-md-12"> <div id = "div_1" class="table-responsive" ng-controller="usercontroller" ng-init="displayData() "> <table class="table table-hover table-borde
<div class="row">
<div class="col-md-12">
<div id = "div_1" class="table-responsive" ng-controller="usercontroller" ng-init="displayData() ">
<table class="table table-hover table-bordered">
<thead align="center">
<tr>
<th>Service Request Number</th>
<th>Name of service request</th>
<th>Date of request</th>
<th>Closure date</th>
<th>Current state</th>
<th>Current owner</th>
<th>Link to share point folder</th>
<th>Schedule variance</th>
<th align="center">Details</th>
</tr>
</thead>
<tbody>
<tr ng-repeat="x in service track by $index">
<td><span ng-bind="x.id"></span></td>
<td><span ng-bind="x.sales_force_id"></span></td>
<td><span ng-bind="x.submission_date"></span></td>
<td><span ng-bind="x.closure_deadline"></span></td>
<td><span ng-bind="x.item_status"></span></td>
<td></td>
<td></td>
<td></td>
$scope.displayData = function()
{
alert($scope.firstRole);
alert("nishant singh");
if(empIVal == 1 && $scope.firstRole == 'Initiator' ){
alert("i am a initiator");
$http.get("commonGet.jsp?sqlStr=select * from service_request.service_request_data where emp_id="+empHidVal+ " order by id desc")
.then(function(response){
$scope.service = response.data;
});
}
服务请求号码
服务请求名称
请求日期
截止日期
现状
当前所有者
链接到共享点文件夹
进度差异
细节
$scope.displayData=函数()
{
警报($scope.firstRole);
警惕(“尼桑·辛格”);
if(empIVal==1&&$scope.firstRole=='Initiator'){
警惕(“我是发起人”);
$http.get(“commonGet.jsp?sqlStr=select*from service_request.service_request_data,其中emp_id=“+empHidVal+”order by id desc”)
.然后(功能(响应){
$scope.service=response.data;
});
}
在这里,当
displayFunction()启动时,我想再次加载div
调用
并返回响应。此外,响应是JSON对象。我可以使用ng change
指令调用函数,也可以获得所需的JSON对象,但我不知道如何在响应后再次加载div
。在超时时将赋值包装到服务变量,以便angular意识到了这些变化
$timeout(function(){
$scope.service = response.data;
});
因此,你的整个方法变成了这样
$http.get("commonGet.jsp?sqlStr=select * from service_request.service_request_data where emp_id="+empHidVal+ " order by id desc")
.then(function(response){
$timeout(function(){
$scope.service = response.data;
});
});
}
在超时时将您的赋值包装到服务变量,以便angular知道这些更改
$timeout(function(){
$scope.service = response.data;
});
因此,你的整个方法变成了这样
$http.get("commonGet.jsp?sqlStr=select * from service_request.service_request_data where emp_id="+empHidVal+ " order by id desc")
.then(function(response){
$timeout(function(){
$scope.service = response.data;
});
});
}
您可以提供samecan的plunker吗?您可以提供sameNo的plunker,实际上基于页面中的某些更改,它需要触发对特定div的刷新,而不是基于超时。我认为如果表中的数据发生更改,您希望刷新div。注意:$timeout并不意味着我们在某个超时上执行它,$timeout有一个n调用$scope的功能。$apply将反映数据中的更改,并使angular了解更改我可以这样写:如何使用$http服务编写此超时函数:$http.get(“commonGet.jsp?sqlStr=select*from service_request.service_request_data where emp_id=“+empHidVal+”order by id desc”).然后(功能(响应){$scope.service=response.data;我尝试了超时,但仍然没有重新加载所需的div。不,实际上根据页面中的某些更改,它需要触发对特定div的刷新,而不是基于超时。我以为如果表中的数据发生更改,您希望刷新div。注意:$timeout不需要这并不意味着我们是在某个超时时间执行它,$timeout可以调用$scope.$apply,它将反映数据中的更改并使angular意识到更改我这样写:如何使用$http service:$http.get编写此超时函数(“commonGet.jsp?sqlStr=select*from service_request.service_request_data where emp_id=“+empHidVal+”order by id desc”)。然后(函数(response){$scope.service=response.data;我尝试了超时,但仍然没有重新加载所需的div。