AngularJS 重新加载页面不起作用

塞尔米尔

更新后我需要刷新列表,我已经尝试了所有解决方案,但没有一个对我有用,我是 Angular 的新手。

我的代码是:

索引.html

<div ng-controller="customersCrtl">
<div class="container">
<br/>
<blockquote><h4>Registro de Ingreso</h4></blockquote>
<br/>
<div class="row">
    <div class="col-md-2">Limite de Pagina:
        <select ng-model="entryLimit" class="form-control">
            <option>10</option>
            <option>50</option>
            <option>100</option>
            <option>250</option>
            <option>500</option>
        </select>
    </div>
    <div class="col-md-3">Buscar Por:
        <input type="text" ng-model="search" ng-change="filter()" placeholder="Carnet de Identidad" class="form-control" />
    </div>
    <div class="col-md-4">
        <h5>Listados {{ filtered.length }} de {{ totalItems}} Clientes registrados</h5>
    </div>
</div>
<br/>
<div class="row">
    <div class="col-md-12" ng-show="filteredItems > 0">
        <table class="table table-striped table-bordered">
        <thead>
        <th>ID Cliente&nbsp;</th>
        <th>Nombre&nbsp;</th>
        <th>eMail&nbsp;</th>
        <th>Detalles&nbsp;</th>
        <th>Marcar Ingreso&nbsp;</th>
        </thead>
        <tbody>
            <tr ng-repeat="data in filtered = (list | filter:search | orderBy : predicate :reverse) | startFrom:(currentPage-1)*entryLimit | limitTo:entryLimit">
                <td>{{data.id}}</td>
                <td>{{data.name}}</td>
                <td>{{data.email}}</td>
                <td>{{data.extras}}</td>
                <td><a ng-click="updateCliente(data.id)" class="pull-right"><i class="glyphicon glyphicon-ok-sign"></i></a></td>
            </tr>
        </tbody>
        </table>
    </div>
    <div class="col-md-12" ng-show="filteredItems == 0">
        <div class="col-md-12">
            <h4>No customers found</h4>
        </div>
    </div>
    <div class="col-md-12" ng-show="filteredItems > 0">    
        <div pagination="" page="currentPage" on-select-page="setPage(page)" boundary-links="true" total-items="filteredItems" items-per-page="entryLimit" class="pagination-small" previous-text="&laquo;" next-text="&raquo;"></div>


    </div>
</div>

和我的 app.js

var app = angular.module('myApp', ['ui.bootstrap']);

app.filter('startFrom', function() {
return function(input, start) {
    if(input) {
        start = +start; //parse to int
        return input.slice(start);
    }
    return [];
}
});
app.controller('customersCrtl', function ($scope, $http, $timeout) {
$http.get('ajax/getCustomers.php').success(function(data){
    $scope.list = data;
    $scope.currentPage = 1; //current page
    $scope.entryLimit = 5; //max no of items to display in a page
    $scope.filteredItems = $scope.list.length; //Initially for no filter  
    $scope.totalItems = $scope.list.length;
});
$scope.setPage = function(pageNo) {
    $scope.currentPage = pageNo;
};
$scope.filter = function() {
    $timeout(function() { 
        $scope.filteredItems = $scope.filtered.length;
    }, 10);
};
$scope.sort_by = function(predicate) {
    $scope.predicate = predicate;
    $scope.reverse = !$scope.reverse;
};
$scope.reload = function() {
    location.reload(); 
}; 
$scope.updateCliente = function (cliente) {
if(confirm("Confirma el ingreso?")){
$http.post("ajax/updateCliente.php?idCliente="+cliente).success(function(data){
    reload();
  });
 }
};

});

在帖子的成功事件上,我需要重新加载。DB 已更新,因此 http.post 的结果必须是 Success。

我也试过用$window.location.reload();代替,location.reload();但没有用。

阿马杜贝

不要忘记你的重载函数在作用域内,所以通过 $scope 调用它。

代替

reload();

经过

$scope.reload();

本文收集自互联网,转载请注明来源。

如有侵权,请联系[email protected] 删除。

编辑于
0

我来说两句

0条评论
登录后参与评论

相关文章

来自分类Dev

AngularJS指令分页重新加载页面不起作用

来自分类Dev

AngularJS UI路由器重新加载不起作用

来自分类Dev

AngularJS Button重新加载状态不起作用

来自分类Dev

删除#我的angularjs页面不起作用

来自分类Dev

页面加载AngularJS时,文本框绑定不起作用

来自分类Dev

preventDefault()不起作用,页面被重新加载

来自分类Dev

AngularJS ::不起作用

来自分类Dev

使用ngroute和ngview的Angularjs路由对我不起作用。单击链接不会加载预期的页面

来自分类Dev

HTML页面上的AngularJS验证不起作用

来自分类Dev

Rails + AngularJS-页面刷新在localhost上不起作用

来自分类Dev

AngularJS承诺不起作用

来自分类Dev

指令不起作用angularjs

来自分类Dev

AngularJS reloadOnSearch不起作用

来自分类Dev

AngularJs $ stateProvider不起作用

来自分类Dev

angularjs getdate不起作用

来自分类Dev

AngularJs 1不起作用

来自分类Dev

AngularJS代码不起作用

来自分类Dev

AngularJS routeProvider不起作用

来自分类Dev

AngularJS路由不起作用

来自分类Dev

AngularJS动画不起作用

来自分类Dev

AngularJS转换不起作用

来自分类Dev

AngularJS视图不起作用

来自分类Dev

AngularJS路由不起作用

来自分类Dev

指令不起作用angularjs

来自分类Dev

角度AngularJS不起作用

来自分类Dev

angularjs显示不起作用

来自分类Dev

AngularJS模块不起作用

来自分类Dev

AngularJS推送不起作用

来自分类Dev

AngularJS路由不起作用