【发布时间】:2019-03-22 05:29:43
【问题描述】:
我需要使用 introjs 来了解 Angular 6 应用程序的新功能。
在我启动 introjs 的组件的子组件中,在游览中,ngFor 中的一些步骤目标项目。该库能够定位子组件 html 元素,但似乎无法定位 ngFor 中的元素。我想要的用法很简单我有一个 li 代表我循环的卡片项目:
<div *ngFor="let source of sourcesDisplay; let idx = index" class="col-lg-5ths col-md-4 col-sm-6 col-xs-12">
<!-- item -->
<div class="item blue-light">
<div class="header">
<div class="categories">
<div class="truncat">{{source.categories.length > 0? source.categories : 'NO CATEGORY'}}</div>
</div>
<a routerLink="{{ organization?.name | routes: 'sources' : source.id }}" class="title">
<div class="truncat">{{source.name}}</div>
</a>
<div class="corner-ribbon blue-light" *ngIf="isARecentSource(source.createdAt)">New</div>
<div class="corner-fav" [class.is-active]="isSourceFavorite(source.id)"
(click)="toggleFavorite(source.id)"><em class="icon-heart-o"></em></div>
</div>
<a class="content" routerLink="{{ organization?.name | routes: 'sources' : source.id }}">
<div class="icon">
<em [ngClass]="source.icon? 'icon-'+source.icon : 'icon-cocktail3'"></em>
</div>
</a>
<div class="actions">
<ul class="buttons three">
<li class="icon-font" ><a (click)="openDashboardModal(source)"
[class.disable]="source.powerbi.length === 0" class="btn-effect"><em
class="icon-chart-bar"></em></a></li>
<li class="icon-font"><a
(click)="openDatalakeModal(source)" [class.disable]="source.datalakePath.length === 0"
class="btn-effect"><em class="icon-arrow-to-bottom"></em></a>
</li>
<li class="icon-font"><a routerLink="{{ organization?.name | routes: 'sources' : source.id }}"
class="btn-effect"><em class="icon-info-circle"></em></a></li>
</ul>
</div>
</div>
</div><!-- /item -->
我想像按钮一样定位这张卡片的一部分,例如:
<li class="icon-font" id="step4{{idx}}">
<a (click)="openDashboardModal(source)" [class.disable]="source.powerbi.length === 0" class="btn-effect">
<em class="icon-chart-bar"></em>
</a>
</li>
然后在我的组件中:
const intro = IntroJs.introJs();
intro.setOptions({
steps: [
{
element: document.querySelector('#step40'),
intro: 'Welcome to the Data Portal ! Explore and download data accross any division. Let\'s discover the new home page.'
}]})
intro.start();
我做错了什么吗? introjs 根本无法做到这一点吗?是否有另一个库可以做到这一点?
提前谢谢你
【问题讨论】:
-
我认为你需要等到
*ngFor被渲染 -
你是在 ngAfterViewInit() 中开始介绍吗?
-
这段代码。 const intro = IntroJs.introJs(); intro.setOptions({ steps: [ { element: document.querySelector('#step40'), intro: '欢迎来到数据门户!探索和下载跨部门的数据。让我们发现新的主页。'} ]}) intro.start();
-
我在 ngOnInit 中启动它,我会在 afterviewinit 上尝试
-
我是在渲染元素后完成的,但仍然无法正常工作:/
标签: javascript angular angular6 ngfor intro.js