2015-01-11 38 views
0

我正在使用reveal.js。我的幻燈片保存在json對象中。出於某種原因,輸出只有一張幻燈片,一切都被覆蓋!這裏是我的代碼:reveal.js:ng-repeat不適用於部分標記

<div class="reveal"> 
       <div class="slides" data-ng-controller="myControl"> 
        <section data-ng-repeat="slide in allSlide"> 
         {{slide}} 
        </section> 
       </div> 
      </div> 

和我的js代碼

$scope.allSlide = [...]; 

我在reveal.js作品有NG-重複,但什麼是與我的問題的代碼here發現了什麼? 任何幫助表示讚賞。 更新:腳本包含像下面的HTML文件的末尾:

<script src="lib/js/head.min.js"></script> 
<script src="js/reveal.js"></script> 

<script> 
    Reveal.initialize({ 

}); 

</script> 
+0

我不認爲你可以這樣做,可能是因爲reveal.js需要在某個時間點進行初始化,並且對於何時angularjs實際創建了內容這一點感到困惑。 –

+0

謝謝@PeterAshwell。這裏https://github.com/robinComa/html5-presentation/blob/master/app/index.html它顯示工作 – Sara

+1

薩拉,你可以請你說明你如何包含腳本? – kurideja

回答

2

這是困難的,因爲angularJS將無法完成的渲染時reveal.js試圖將HTML解釋成幻燈片。你可以嘗試以下方法,這是從您發佈的鏈接,這是工作:

<script> 
    setTimeout(function() { 
     Reveal.initialize({}); 
    }, 200); 
</script> 

下面是從您發佈的工作演示的相關線路:

https://github.com/robinComa/html5-presentation/blob/master/app/scripts/modules/reveal.js#L26

 setTimeout(function(){ 
      Reveal.initialize({ 
       controls: true, 
       progress: true, 
       history: true, 
       center: true, 

       theme: Reveal.getQueryHash().theme, // available themes are in /css/theme 
       transition: Reveal.getQueryHash().transition || 'default', // default/cube/page/concave/zoom/linear/fade/none 
       // ... some stuff in here 
      }); 
     }, 200); 

也許預先定義幻燈片的結構而不是使用ng-repeat會是一個好主意?也許在沒有ng-repeat的情況下佈置這些部分(這樣顯示就可以在沒有超時的情況下進行解釋),然後使用ng-include將您的重複佈局放入每個部分塊中。

+0

謝謝彼得。我對Angular很新穎。你能告訴我一個例子嗎? – Sara

+0

超時解決方案的工作原理,但我認爲這不是一個好主意。 – Sara

+0

這不是,但沒有使用某種可能存在的reveal.js的angular-wrapped版本,這將是一個問題。 –