Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/angularjs/20.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript Angularjs ng repeat未使用更新的值刷新_Javascript_Angularjs - Fatal编程技术网

Javascript Angularjs ng repeat未使用更新的值刷新

Javascript Angularjs ng repeat未使用更新的值刷新,javascript,angularjs,Javascript,Angularjs,我有一个在弹出窗口(ngdialog)上插入和更新记录的功能。当Im添加和更新记录时,在数据库中插入和更新记录,但这些更新的值不使用ng repeat绑定 仅当我刷新整个页面时,才会显示更新的记录 控制器代码: $scope.OpenUserPlaceMap = function (userplace) { if (angular.isObject(userplace)) { $scope.UserPlaceID = userplace.Id; $sco

我有一个在弹出窗口(ngdialog)上插入和更新记录的功能。当Im添加和更新记录时,在数据库中插入和更新记录,但这些更新的值不使用ng repeat绑定

仅当我刷新整个页面时,才会显示更新的记录

控制器代码:

 $scope.OpenUserPlaceMap = function (userplace) {
    if (angular.isObject(userplace)) {
        $scope.UserPlaceID = userplace.Id;
        $scope.UserPlaceName = userplace.Name;
        $scope.FormattedAddress = userplace.FormattedAddress;
    }
    else {
        $scope.UserPlaceID = '';
        $scope.UserPlaceName = '';
        $scope.FormattedAddress = '';
    }
    ngDialogAlert.ShowPopup('UserPlacesMap.html', 'CommanCtrl', $scope);
};

$scope.SubmitUserPlace = function (flg) {
    $scope.error = [];

    var UserPlace = {
        "Id": $scope.UserPlaceID,
        "UserId": $scope.UserId,
        "Name": $scope.UserPlaceName,
        "FormattedAddress": $scope.FormattedAddress,
        "CircleID": $scope.DefaultCircle,
        "Latitude": $scope.Latitude,
        "Logitude": $scope.Logitude,
        "Flag": flg
    };
    SWT360Service.InUpdDelUserPlace(UserPlace).success(function (data) {
        if (data > 0) {

            ngDialogAlert.ClosePopup();
            $scope.error.push('Saved Successfully');
            ngDialogAlert.ShowAlert(true, $scope.error);
            $scope.LoadUserPlaces();
        }
        else {
            $scope.error.push('User Place not saved Successfully !');
        }
    }).error(function (data) {
        $scope.error.push(data);
    });
}
 $scope.LoadUserPlaces = function () {
    $scope.UserPlaces = '';
    SWT360Service.GetUserPlace(null, $scope.UserId, $scope.DefaultCircle).success(function (data) {
            $scope.UserPlaces = data;
    });
};
视图:


{{place.id}{{place.Name}}
{{place.FormattedAddress}}


尝试在
用户位置添加一个观察者,如下图所示,并将所有内容包装在其中$监视和更新范围

$scope.OpenUserPlaceMap=函数(userplace){
if(角度等对象(用户位置)){
$scope.UserPlaceID=userplace.Id;
$scope.UserPlaceName=userplace.Name;
$scope.FormattedAddress=userplace.FormattedAddress;
}
否则{
$scope.UserPlaceID='';
$scope.UserPlaceName='';
$scope.FormattedAddress='';
}
ngDialogAlert.ShowPopup('UserPlacesMap.html','CommanCtrl',$scope);
};
$scope.$watch('UserPlaces',函数(UserPlaces){
$scope.SubmitUserPlace=函数(flg){
$scope.error=[];
var UserPlace={
“Id”:$scope.UserPlaceID,
“UserId”:$scope.UserId,
“名称”:$scope.UserPlaceName,
“FormattedAddress”:$scope.FormattedAddress,
“CircleID”:$scope.DefaultCircle,
“纬度”:$scope.Latitude,
“Logitude”:$scope.Logitude,
“旗帜”:flg
};
SWT360Service.InUpdDelUserPlace(UserPlace).success(函数(数据){
如果(数据>0){
ngDialogAlert.ClosePopup();
$scope.error.push('Saved Successfully');
ngDialogAlert.ShowAlert(true,$scope.error);
$scope.LoadUserPlaces();
}否则{
$scope.error.push('User Place未成功保存!');
}
}).错误(函数(数据){
$scope.error.push(数据);
});
}
$scope.LoadUserPlaces=函数(){
$scope.UserPlaces='';
SWT360Service.GetUserPlace(null,$scope.UserId,$scope.DefaultCircle)。成功(函数(数据){
$scope.UserPlaces=数据;
});
};
});

a感谢您的回复。Im在Userplaces对象中获取更新的记录,但ng repeat在绑定后不会刷新。
 <div class="container" ng-repeat="place in UserPlaces" style="cursor:pointer;" ng-click="OpenUserPlaceMap(place);">
                    <div class="col-lg-12 bg-success text-center">
                        <i class="fa fa-map-marker"></i> <span style="display:none;">{{place.id}}</span> <span>{{place.Name}}</span> <br />
                        <span>{{place.FormattedAddress}}</span><br>
                    </div>
                    <div class="clearfix"></div>
                    <hr>
                </div>