2017-12-15 14 views
0

In this plunk開かれたときに1秒間表示されずに表示される角度UIモーダルがあります。私はテンプレート自体にng-showを使用していますが、モーダルではなく内容を隠しています。モーダルを隠すには?モーダルはconsole.log("displayed")を待たずにconsole.log("opened")の直後に表示されることに注意してください。開かれた1秒後に角度UIモーダルを表示

Javascriptを:

var app = angular.module('app', ['ui.bootstrap']); 
app.controller('ctl', function() {}); 

app.directive("theModal", function($uibModal,$timeout) { 
      return { 
      restrict: "AE",   
      link: function (scope, element, attrs) { 

        scope.show = false; 
        console.log("opened"); 
        scope.instance = $uibModal.open({ 
         windowClass: 'app-modal', 
         template: '<div ng-show="show">MODAL WAS LOADED</div>' 
        }); 

        $timeout(function(){ 
         scope.show = true; 
         console.log("displayed"); 
        },1000) 

      } 
     } 
    }); 

答えて

1

残念ながら、これは私が将来的に終了関数としてタイムアウトを使用しますが、私の本当で質問に、私の場合には動作しません。この

var app = angular.module('app', ['ui.bootstrap']); 
app.controller('ctl', function() {}); 

app.directive("theModal", function($uibModal,$timeout) { 
     return { 
     restrict: "AE",   
     link: function (scope, element, attrs) { 

       console.log("opened"); 

       $timeout(function(){ 
        scope.instance = $uibModal.open({ 
        windowClass: 'app-modal', 
        template: '<div >MODAL WAS LOADED</div>' 
        }); 
        console.log("displayed"); 
       },1000) 

     } 
    } 
}); 
+0

をお試しくださいシナリオはタイムアウトではなく、別の機能です。この関数が終了するまで待ち、showフラグをtrueに設定する必要があります。 – ps0604

+0

'..and then then set the ...'と約束してください。 – svarog

+0

@svarogはい、私は約束をすることができますが、 'show/hide'フラグはコンテンツレベルではなくモーダルレベルで設定する必要があります、それは主な困難です。 – ps0604

関連する問題