2016-08-22 50 views
1

我正在开发一个角js和靴子的网站。如何使用Angular Js + bootsrap设置弹出窗口?

当网站加载我正在做一些服务器调用来获取一些数据。这个过程需要一些时间。在这段时间内,我想显示一个等待消息弹出。

但我卡在这里如何与我的设置。 在app.js中,在run方法中我想添加弹出调用来显示并隐藏一次执行完成。

.run(["$log", "$rootScope", "$state", "dtoResource", "questionResource", function ($log, $rootScope, $state, dtoResource, questionResource) { 
        dtoResource.rc1Step1DTO() 
          .then(function (data) { 
           $rootScope.AutoQuote = data; 
           questionResource.getQuestions($rootScope.AutoQuote.postAutoQuoteObj.SessionInfo.StateCode) 
             .then(function (questions) { 
              $rootScope.questions = questions; 
              $rootScope.answers = {PC: 12345}; 
               console.log('Copy operation'); 
           angular.copy($rootScope.answers,$rootScope.default); 
           console.log($rootScope.answers); 
           console.log($rootScope.default); 
              }) 
          }) 
          .then(function() { 
           //console.log('This should be printed after the above methods are done  executing'); 
           // console.log($rootScope); 

          }) 

       }]) 
Below is plunker link 

https://plnkr.co/edit/aV65Nab9U9I6YlK2g4sY?p=preview

回答

-1

在HTML代码中添加

<div id="loading" class="hidden"><p>loading</p></div> 

之前使得服务器添加以下内容:

$("#loading").removeClass("hidden"); 

,只是接收来自服务器插件响应后:

$("#loading").addClass("hidden"); 
1

你是在正确的轨道上。您需要在您的应用程序中包含角引导程序$ uibmodal模块,然后您准备好

在调用save方法的模式上打开。下面的方法完成这项工作。

var instance = $modal.open(); 

坚持实例并根据保存的响应适当地调用它。

instance.dismiss(); 

以上将关闭您的信息弹出窗口。

看看我为你创造的plunker。获得ip地址相当快,但它模仿你的解决方案。

+0

我可以在不使用ui-bootstrap-tpls-2.1.1.js,1.5.8/angular-animate.js,1.5.8/angular-sanitize.js的情况下创建弹出式窗口,这在应用程序中看起来很管用。 –

+0

我同意这是一个小的开销。您可以放弃角度动画,但您需要该模板。如果你没有使用Sanitize,那么你错过了角度的功能。 – Alok

+0

现在无论我使用的是在我的抢劫者。 –