Skip to content

Commit

Permalink
Use new scope for directive. Allows multiple spinners on page.
Browse files Browse the repository at this point in the history
  • Loading branch information
spieszko committed Aug 12, 2013
1 parent 0f2af72 commit 6f1b20e
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 1 deletion.
1 change: 1 addition & 0 deletions angular-spinner.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
angular.module('angularSpinner', [])
.directive('usSpinner', function ($window) {
return {
scope: true,
link: function (scope, element, attr) {
scope.spinner = null;
scope.$watch(attr.usSpinner, function (options) {
Expand Down
2 changes: 1 addition & 1 deletion angular-spinner.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 10 additions & 0 deletions tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,16 @@ describe('Directive: us-spinner', function () {
expect(Spinner.prototype.stop).not.toHaveBeenCalled();
}));

it('should start spinning the second spinner without stopping the first one', inject(function ($rootScope, $compile) {
var element = angular.element('<div us-spinner></div>');
element = $compile(element)($rootScope);
var secondElement = angular.element('<div us-spinner></div>');
secondElement = $compile(element)($rootScope);
$rootScope.$digest();
expect(Spinner.prototype.spin.callCount).toBe(2);
expect(Spinner.prototype.stop).not.toHaveBeenCalled();
}));

it('should set spinner options as given in attribute', inject(function ($rootScope, $compile) {
var element = angular.element('<div us-spinner="{width:15}"></div>');
element = $compile(element)($rootScope);
Expand Down

0 comments on commit 6f1b20e

Please sign in to comment.