Skip to content

Commit

Permalink
Expose steps reference on the controller.
Browse files Browse the repository at this point in the history
  • Loading branch information
omichelsen committed Jan 7, 2017
1 parent abf590e commit 3ac82db
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 3 deletions.
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ Start creating some steps around your UI:
</steps>
```

The main `<steps>` directive has the following (optional) properties:
The main `<steps>` directive has the following (optional) attributes:

- **name**: Name of the group of steps. Use if you have multiple `<steps>` to
reference them in the `ServiceHandler`.
Expand Down Expand Up @@ -114,6 +114,8 @@ You can use the following functions on `StepsService.steps()`:
- **goTo(** *number* | *name* **)**: Go to a specific step. Argument can be
either a number (zero-based index) or the **name** of a step.

You can get the number of steps from `StepsService.steps().steps.length`.

#### Multiple steps

If you have multiple `<steps>` in your page and wish to access them from the
Expand Down
4 changes: 2 additions & 2 deletions src/angular-steps.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,13 +47,13 @@
return attributes.template || 'steps.html';
},
controller: function ($scope, $element, StepsService) {

StepsService.addSteps($scope.name || StepsService.defaultName, this);

$scope.$on('$destroy', function () {
StepsService.removeSteps($scope.name || StepsService.defaultName);
});

$scope.steps = [];
this.steps = $scope.steps = [];

$scope.$watch('currentStep', function (step) {
if (!step) return;
Expand Down
4 changes: 4 additions & 0 deletions test/angular-steps.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,10 @@ describe('AngularSteps', function () {
expect(scope.referenceCurrentStep).toEqual('Starting');
});

it('should expose steps reference', function () {
expect(StepsService.steps().steps.length).toEqual(3);
});

it('should go to the next step', function () {
expect(scope.referenceCurrentStep).toEqual('Starting');
StepsService.steps().next();
Expand Down

0 comments on commit 3ac82db

Please sign in to comment.