2016-08-23 45 views
11

我試圖使用ng-tour插件將遊覽添加到網絡應用:http://daftmonk.github.io/angular-tour/ 插件主頁上的示例在單個網頁上完成我很難找出如何在角度的web應用上實現這一點。添加以下到我的index.html:如何在角度網絡應用上實現角度遊覽

我的代碼:

加入遊步id來一個觀點:

<div ui-view="portal" ng-show="$state.includes('portal')" id="e0"></div> 

在我的index.html文件的底部:

<tour step="currentStep"> 
    <virtual-step tourtip="test " tourtip-element="#e0" tourtip-next-label="next" tourtip-placement="right" tourtip-step="0" ></virtual-step> 

    </tour> 
    </body> 
</html> 

當應用程序路由到門戶視圖時沒有任何反應......我應該將ng-tour標籤添加到單個視圖HTML模板中嗎?我最初嘗試過,但也無法使其工作。

+0

你的控制檯中有什麼?您是否將角度巡視添加到模塊作爲依賴項? 'angular.module('myApp',['angular-tour'])' – adamdport

+0

https://github.com/DaftMonk/angular-tour#virtual-steps – adamdport

+0

@adamdport是的,我沒有添加它作爲依賴項。不,我沒有看到我的控制檯中的任何東西。 – user2094257

回答

2

如果您未在控制器中初始化currentStep,它將默認設置爲-1,這意味着巡視不會在頁面加載時顯示。 -Angular tour documentation

所以一定要在你的控制器初始化$scope.currentStep

關於多個視圖,the virtual steps section of the documentation表示您可以在一個地方定義所有步驟,並使用tourtip-element="#element-from-another-view"僅針對不同視圖中的元素。當你得到這個提示時,這些觀點當然必須在DOM上。