如何刷新NG-repeat中的数据
这是设置
控制器:
angular.module('pApp').controller('KController', ['$scope', 'getInfo', 'addInfo', function ($scope, getInfo, addInfo)
{
$scope.add = function (a, b, c) {
var items = [];
items.push(a, b, c);
addInfo.addP(items).success(function () {
$scope.updatedprocess();
});
});
}
$scope.updatedprocess = function () {
getInfo.getP().success(function (data) {
$scope.pInfo = data.d.results;
})
};
$scope.updatedprocess();
}]);
服务
angular.module('pApp').service('getInfo', function ($window, $http) {
var requestDigest = $window.document.getElementById("__REQUESTDIGEST").value;
JSRequest.EnsureSetup();
var hostweburl = decodeURIComponent(JSRequest.QueryString["SPHostUrl"]);
var appweburl = decodeURIComponent(JSRequest.QueryString["SPAppWebUrl"]);
this.getP = function () {
var requestUrl = appweburl + "/_api/SP.AppContextSite(@target)/web/lists/getbytitle('Processes')/items?@target='" + hostweburl + "'";
return $http({
url: requestUrl,
method: "GET",
headers: {
"accept": "application/json;odata=verbose"
}
});
};
HTML(查看)
<input class="productDDL" ng-model="query" type="text" id="dropdownMenu2" data-toggle="dropdown" aria-haspopup="true" aria-expanded="true" placeholder="{{selectedProduct}}" >
<ul class="dropdown-menu" aria-labelledby="dropdownMenu2" >
<li ng-repeat="product in pInfo| filter: query | orderBy: 'name' track by product.Id"><a href="" ng-click="selectProduct(product.Title)">{{product.Title}}</a></li>
</ul>
我正在使用modal将信息添加到List
<div class="modal-footer"><button type="button" class="btn btn-default" ng-click="close()">Close</button>
<button type="submit" class="btn btn-primary" ng-click="add(locationname,ddlproductTypes,ddlBusinessUnits)">Add</button>
</div>
提交按钮调用控制器中的$ scope.add()函数。
$ scope中的值正在更新
但是在视图中,没有页面刷新,Ng-repeat没有更新
请帮我看看如何动态更新
谢谢