2016-08-23 47 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上。