在angular2 cli中使用mdl-stepper事件

时间:2017-05-16 06:55:35

标签: angular

我在通过CLI(https://ahlechandre.github.io/mdl-stepper/component/)创建的angular2项目中使用mdl-stepper。 DOM升级后正确呈现。 JS和CSS包含在我的angular-cli.json中:

  "styles": [
    "styles.css",
    "../node_modules/material-design-lite/dist/material.amber-blue.min.css",
    "../node_modules/mdl-stepper/stepper.css"
  ],
  "scripts": [
    "../node_modules/material-design-lite/material.min.js",
    "../node_modules/mdl-stepper/stepper.min.js"

  ],

然而,要实现其方法,如next(),back()等。我不知道应该在我的组件中导入什么以及如何导入?

该示例显示以下内容:

var stepperElement = document.querySelector('.mdl-stepper');
// Get the MaterialStepper instance of element.
var Stepper = stepperElement.MaterialStepper;
// Select any step other than the first (for obvious reasons).
var step = element.querySelector('.mdl-step:nth-child(2)');

step.addEventListener('onstepback', function (event) {
  // When the step (this) action button/link with [data-stepper-back] attribute is clicked
  // you can call the back() method or do anything else.
  Stepper.back();
});

特定var Stepper = stepperElement.MaterialStepper;会引发错误,指出MaterialStepper未定义。

0 个答案:

没有答案