@adeteam/ngx-stepper 中文文档教程

发布于 5年前 浏览 3 项目主页 更新于 3年前

ngx-stepper

器的角度材料的角度步进器指令

基于材料步进

Plunker Demo

:https://www.google.com/design/spec/components/steppers.html#steppers-types-of-steppers http://embed.plnkr.co/n1Ye3pQY6dlMSoJizO6Y/

Run Demo App

您可以在使用 角度 CLI

#1 To start the demo app clone or download the repo.

#2 Install the latest version of Angular-CLI

npm install -g angular-cli@latest

#3 Install npm packages

npm install

#4 Run the app

ng serve

#5 Open the app

http://localhost:4200/

Installation in package.json

npm i -S ngx-stepper

注意:适用于 angular 2 & 4```html

Import to app module

import { NgxStepperModule } from 'ngx-stepper';

@NgModule({
  declarations: [
    AppComponent
  ],
  imports: [
    BrowserModule,
    NgxStepperModule
  ],
  providers: [],
  bootstrap: [AppComponent]
})
export class AppModule { }

Write your html


Lorem ipsum dolor sit amet, consectetur adipisicing elit。 Consectetur nobis saepe facere suscipit atque, sapiente, natus mollitia ipsum odit accusamus repellendus deserunt。 Odio sit similique,labore maxime voluptatibus, eaque autem!

Lorem ipsum dolor sit amet, consectetur adipisicing elit。 Consectetur nobis saepe facere suscipit atque, sapiente, natus mollitia ipsum odit accusamus repellendus deserunt。 Odio sit similique,labore maxime voluptatibus, eaque autem!

Lorem ipsum dolor sit amet, consectetur adipisicing elit。 Consectetur nobis saepe facere suscipit atque, sapiente, natus mollitia ipsum odit accusamus repellendus deserunt。 Odio sit similique,labore maxime voluptatibus, eaque autem!

Lorem ipsum dolor sit amet, consectetur adipisicing elit。 Consectetur nobis saepe facere suscipit atque, sapiente, natus mollitia ipsum odit accusamus repellendus deserunt。 Odio sit similique,labore maxime voluptatibus, eaque autem!

Lorem ipsum dolor sit amet, consectetur adipisicing elit。 Consectetur nobis saepe facere suscipit atque, sapiente, natus mollitia ipsum odit accusamus repellendus deserunt。 Odio sit similique,labore maxime voluptatibus, eaque autem!

# Stepper Options

**options attribute**

Value of the options attribute is a type of StepperOptions. It can contain the following properties.

Detailed property bellow:

| Options | Default | Type | Description |
| --- | --- | --- | -- |
| **vertical** | false | boolean |  |
| **linear** | true | boolean |  |
| **alternative** | true | boolean |  |
| **mobileStepText** | true | boolean |  |
| **labelStep** | 'Step' | string |  |
| **labelOf** | 'Of' | string |  |
| **enableSvgIcon** | false | boolean |  |

# Stepper Service

Used to control a stepper by it's id. Example:

TS @ViewChild('stepperDemo') 公共步进器:NgxStepperComponent;

公共 selectCampaign(): void { this.steppers.showFeedback('正在检查,请稍候......'); 这个.steppers.next(); }

Detailed service operations bellow:

| Method | Description | Returns |
| --- | --- | --- |
| `next()` | Complete the current step and move one to the next. Using this method on editable steps (in linear stepper) it will search by the next step without "completed" state to move. When invoked it dispatch the event onstepcomplete to the step element. | boolean - True if move and false if not move (e.g. On the last step) | 
| `back()` | Move to the previous step without change the state of current step. Using this method in linear stepper it will check if previous step is editable to move. | boolean - True if move and false if not move (e.g. On the first step) |
| `skip()` | Move to the next step without change the state of current step. This method works only in optional steps. | boolean - True if move and false if not move (e.g. On non-optional step) |
| `goto(stepNumber: number)` | Move "active" to specified step id parameter. The id used as reference is the integer number shown on the label of each step (e.g. 2). | boolean - True if move and false if not move (e.g. On id not found) |
| `error(message: string)` | Defines the current step state to "error" and shows the message parameter on title message element.When invoked it dispatch the event onsteperror to the step element. | {string} message The error message |
| `clearError()` | Defines the current step state to "normal" and removes the message parameter on title message element. | void |
| `showFeedback(message?: string)` | Shows a feedback message and a loading indicador. | void |
| `clearFeedback()` | Removes the feedback. |  void |

# Embed SVG Icon assets
- Supported Namespace: 'step-done', 'step-warning'

TS 从“@angular/platform-b​​rowser”导入{DomSanitizer}; 从'@angular/material'导入{MdIconRegistry};

公共选项:StepperOptions = { enableSvgIcon:真 };

构造函数(私有_iconRegistry:MdIconRegistry,私有_sanitizer:DomSanitizer){}

公共ngOnInit():void { this.icon注册表 .addSvgIcon('step-done', this.sanitizer.bypassSecurityTrustResourceUrl('YOURICONURL')); this.icon注册表 .addSvgIcon('step-warning', this.sanitizer.bypassSecurityTrustResourceUrl('YOURICONURL')); } ```

  • EX: 'YOURICONURL' = 'assets/icon/warning.svg'

TODO

  • [x] Horizontal steppers
  • [x] Vertical steppers
  • [x] Linear steppers
  • [x] Non-linear steppers
  • [x] Alternative labels
  • [x] Optional steps
  • [ ] Editable steps
  • [x] Stepper feedback
  • Mobile steppers
    • [x] Mobile step text
    • [ ] Mobile step dots
    • [ ] Mobile step progress bar
  • [x] Correct apply styles (css) of the material design
  • [x] Embed SVG Icon assets
  • [ ] Create a better demo page with all options.

Remarks

ngx-stepper

Angular Steppers directive for Angular Material

Based on Material Steppers: https://www.google.com/design/spec/components/steppers.html#steppers-types-of-steppers

Plunker Demo

http://embed.plnkr.co/n1Ye3pQY6dlMSoJizO6Y/

Run Demo App

You can try out the Angular Steppers in the demo app built with Angular-CLI.

#1 To start the demo app clone or download the repo.

#2 Install the latest version of Angular-CLI

npm install -g angular-cli@latest

#3 Install npm packages

npm install

#4 Run the app

ng serve

#5 Open the app

http://localhost:4200/

Installation in package.json

npm i -S ngx-stepper

note: works with angular 2 & 4

Import to app module

import { NgxStepperModule } from 'ngx-stepper';

@NgModule({
  declarations: [
    AppComponent
  ],
  imports: [
    BrowserModule,
    NgxStepperModule
  ],
  providers: [],
  bootstrap: [AppComponent]
})
export class AppModule { }

Write your html

```html

Lorem ipsum dolor sit amet, consectetur adipisicing elit. Consectetur nobis saepe facere suscipit atque, sapiente, natus mollitia ipsum odit accusamus repellendus deserunt. Odio sit similique, labore maxime voluptatibus, eaque autem!

Lorem ipsum dolor sit amet, consectetur adipisicing elit. Consectetur nobis saepe facere suscipit atque, sapiente, natus mollitia ipsum odit accusamus repellendus deserunt. Odio sit similique, labore maxime voluptatibus, eaque autem!

Lorem ipsum dolor sit amet, consectetur adipisicing elit. Consectetur nobis saepe facere suscipit atque, sapiente, natus mollitia ipsum odit accusamus repellendus deserunt. Odio sit similique, labore maxime voluptatibus, eaque autem!

Lorem ipsum dolor sit amet, consectetur adipisicing elit. Consectetur nobis saepe facere suscipit atque, sapiente, natus mollitia ipsum odit accusamus repellendus deserunt. Odio sit similique, labore maxime voluptatibus, eaque autem!

Lorem ipsum dolor sit amet, consectetur adipisicing elit. Consectetur nobis saepe facere suscipit atque, sapiente, natus mollitia ipsum odit accusamus repellendus deserunt. Odio sit similique, labore maxime voluptatibus, eaque autem!

# Stepper Options

**options attribute**

Value of the options attribute is a type of StepperOptions. It can contain the following properties.

Detailed property bellow:

| Options | Default | Type | Description |
| --- | --- | --- | -- |
| **vertical** | false | boolean |  |
| **linear** | true | boolean |  |
| **alternative** | true | boolean |  |
| **mobileStepText** | true | boolean |  |
| **labelStep** | 'Step' | string |  |
| **labelOf** | 'Of' | string |  |
| **enableSvgIcon** | false | boolean |  |

# Stepper Service

Used to control a stepper by it's id. Example:

ts @ViewChild('stepperDemo') public steppers: NgxStepperComponent;

public selectCampaign(): void { this.steppers.showFeedback('Checking, please wait …'); this.steppers.next(); }

Detailed service operations bellow:

| Method | Description | Returns |
| --- | --- | --- |
| `next()` | Complete the current step and move one to the next. Using this method on editable steps (in linear stepper) it will search by the next step without "completed" state to move. When invoked it dispatch the event onstepcomplete to the step element. | boolean - True if move and false if not move (e.g. On the last step) | 
| `back()` | Move to the previous step without change the state of current step. Using this method in linear stepper it will check if previous step is editable to move. | boolean - True if move and false if not move (e.g. On the first step) |
| `skip()` | Move to the next step without change the state of current step. This method works only in optional steps. | boolean - True if move and false if not move (e.g. On non-optional step) |
| `goto(stepNumber: number)` | Move "active" to specified step id parameter. The id used as reference is the integer number shown on the label of each step (e.g. 2). | boolean - True if move and false if not move (e.g. On id not found) |
| `error(message: string)` | Defines the current step state to "error" and shows the message parameter on title message element.When invoked it dispatch the event onsteperror to the step element. | {string} message The error message |
| `clearError()` | Defines the current step state to "normal" and removes the message parameter on title message element. | void |
| `showFeedback(message?: string)` | Shows a feedback message and a loading indicador. | void |
| `clearFeedback()` | Removes the feedback. |  void |

# Embed SVG Icon assets
- Supported Namespace: 'step-done', 'step-warning'

ts import {DomSanitizer} from '@angular/platform-browser'; import {MdIconRegistry} from '@angular/material';

public options: StepperOptions = { enableSvgIcon: true };

constructor(private _iconRegistry: MdIconRegistry,private _sanitizer: DomSanitizer) {}

public ngOnInit(): void { this.iconRegistry .addSvgIcon('step-done', this.sanitizer.bypassSecurityTrustResourceUrl('YOURICONURL')); this.iconRegistry .addSvgIcon('step-warning', this.sanitizer.bypassSecurityTrustResourceUrl('YOURICONURL')); } ```

  • EX: 'YOURICONURL' = 'assets/icon/warning.svg'

TODO

  • [x] Horizontal steppers
  • [x] Vertical steppers
  • [x] Linear steppers
  • [x] Non-linear steppers
  • [x] Alternative labels
  • [x] Optional steps
  • [ ] Editable steps
  • [x] Stepper feedback
  • Mobile steppers
    • [x] Mobile step text
    • [ ] Mobile step dots
    • [ ] Mobile step progress bar
  • [x] Correct apply styles (css) of the material design
  • [x] Embed SVG Icon assets
  • [ ] Create a better demo page with all options.

Remarks

    我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
    原文