获取Angular值,但只有在刷新页面后才能看到图像

时间:2018-03-13 09:46:35

标签: html angularjs image

我正在使用ng-repeat显示用户列表,我正在编辑数据并上传图片。上传数据后整个页面刷新但img不可见,但是如果我检查我在src中获取正确的URL,再次刷新页面然后只有图像可见......

我的观点.js

<figure ng-if="loading_file==false && nodata==false" ng-repeat="user in userdetailslist | orderBy : 'firstname' | filter:searchtext | filter:{role_id:filterbyrole}" ng-class-even="'right'">
     <div >
    <img ng-if="user.profile_img!=null" data-ng-src="https://{{bucketname}}.s3.amazonaws.com/{{user.user_id}}/profilepic/{{user.profile_img}}" alt="Images" />
    <img ng-if="user.profile_img==null" ng-src="/uploads/default.png" alt="Images" />
    </div>
    <h5>{{user.firstname}} {{user.lastname}}</h5>
    <h6>{{user.email}}</h6>
    <h6>Created on {{user.created_date | date: "dd-MMM-yyyy"}}</h6>
    <div class="action_bl">
    <% if(valid_role[1]) { %>
    <span class="action edit" id="edit" ng-hide="deleteclicks">
    <a  ng-click= "edit(user)"   href="javascript:void(0)"></a>
    </span>
    <% } %>
    <% if(valid_role[2]) { %>
    <span class="retore_styl" ng-show="deleteclicks">
    <a   ng-click= "restore(user)" style="color:#7b878d; text-decoration:none" class="fa fa-undo" data-title="Restore" data-toggle="modal" data-target="#restorediag" href="javascript:void(0)"></a>
     </span>
    <span class="action" >
    <a ng-click= "delete(user)" data-title="Delete" data-toggle="modal" data-target="#delete" href="javascript:void(0)"></a>
    </span>
    <% } %>
    </div>
    </figure>

我的app.js

$scope.getuserdata=function(status)
        {
              $scope.loading_file = true;
            $scope.status=status;
            $http.get('/getuserswithstatus/'+$scope.status).then(function(response)
            {
                 $scope.userdetailslist = response.data;  

                 $scope.loading_file = false;
                 if($scope.userdetailslist.length==0)
                 {
                     $scope.nodata=true;
                 }
                 else
                 {
                    $scope.nodata=false; 
                 }
            }); 

在更新ng-src中的数据后获取链接,但是单独的图像不可见,我的代码中有任何错误

0 个答案:

没有答案