我们是否可以延迟angularjs中的渲染,直到所有变量从回调中获得所需的值 更新

我们是否可以延迟angularjs中的渲染,直到所有变量从回调中获得所需的值 更新,angularjs,callback,rendering,ng-init,Angularjs,Callback,Rendering,Ng Init,1-IsShopthowTerminated返回预期的true,但值不会反映在视图中 我分享了angularjs代码。 其中,IsShopthowTerminated始终未定义,且未描述所需的值 我认为问题在于,它首先呈现,然后更改isshoptoshowtheterminated的值。 搜索之后,我越来越困惑 $scope.isshoptoshowtheterminated=函数(shopTerminationDate){ setTimeout(函数(){ 调试器; 如果($scope.I

1-IsShopthowTerminated返回预期的true,但值不会反映在视图中


我分享了angularjs代码。 其中,
IsShopthowTerminated
始终未定义,且未描述所需的值

我认为问题在于,它首先呈现,然后更改
isshoptoshowtheterminated
的值。 搜索之后,我越来越困惑

$scope.isshoptoshowtheterminated=函数(shopTerminationDate){
setTimeout(函数(){
调试器;
如果($scope.IsTerminated($scope.viewCompany.TerminationDate)){
返回true;
}否则{
返回$scope.IsTerminated(shopTerminationDate);
}
},
0);
}

{{isTerminatedValue}}
结束
活跃的

您可以通过添加ngIf指令来延迟渲染,该指令将检查isTerminatedValue的值是否为undefined

<td ng-init="isTerminatedValue = IsShopToShowTerminated(shop.TerminatinonDate)">
    <div ng-if="isTerminatedValue">
        {{isTerminatedValue}}
        <div ng-show="isTerminatedValue">
            <i class="fa fa-circle text-danger"></i>
            <small>Terminated</small>
        </div>
        <div ng-show="isTerminatedValue">
            <i class="fa fa-circle text-success"></i>
            <small>Active</small>
        </div>
    </div>  
</td>

{{isTerminatedValue}}
结束
活跃的

最好不要在all@PetrAveryanovshop.TerminationNode对于循环中的每个商店都是不同的。您是否建议我在所有事件中写入ng show=“Isshoptoshowtheterminated(shop.terminatendate)”我建议您在控制器中写入ng show=“smth.isTerminatedValue”和init,为每个tdumm更新此值,这听起来可能有点傻,但您的shop变量是否在控制器中定义为$scope.shop?