【发布时间】:2019-06-24 13:49:40
【问题描述】:
我正在使用 angular 6 的 materialize-stepper。从文档中我必须编写一些 HTML,然后初始化 DOM 元素,如
let stepperInstace = new MStepper(stepper, {
// options
firstActive: 0 // this is the default
})
还有 HTML
<ul class="stepper linear" #contentTypeStepper>
<li class="step active">
<div class="step-title waves-effect">E-mail</div>
<div class="step-content">
<!-- Your step content goes here (like inputs or so) -->
<div class="step-actions">
<!-- Here goes your actions buttons -->
<button class="waves-effect waves-dark btn next-step">CONTINUE</button>
</div>
</div>
</li>
<li class="step">
<div class="step-title waves-effect">Data</div>
<div class="step-content">
<!-- Your step content goes here (like inputs or so) -->
<div class="step-actions">
<!-- Here goes your actions buttons -->
<button class="waves-effect waves-dark btn next-step">CONTINUE</button>
</div>
</div>
</li>
</ul>
和 angular.json
中的 CSS 条目"styles": [
"node_modules/materialize-stepper/dist/css/mstepper.css"
]
在 ts 中我像导入它一样
import MStepper from "materialize-stepper/dist/js/mstepper";
@ViewChild("contentTypeStepper")
contentTypeStepper: ElementRef;
iContentTypeStepper: any;
并像初始化它一样
ngAfterViewInit(): void {
console.log("TCL: AdminContentTypeDetailComponent -> MStepper", MStepper);
this.iContentTypeStepper = MStepper.constructor(this.contentTypeStepper.nativeElement, {
firstActive: 0 // this is the default
});
}
但这不起作用。可能是什么问题?
【问题讨论】:
标签: angular materialize materialize-stepper