Skip to content
This repository has been archived by the owner on Oct 1, 2023. It is now read-only.

Commit

Permalink
Merge pull request #12 from aaronroberson/master
Browse files Browse the repository at this point in the history
Added support for expressions in attributes
  • Loading branch information
urish committed Apr 25, 2014
2 parents 185b522 + 744e26a commit c4dae9e
Showing 1 changed file with 15 additions and 13 deletions.
28 changes: 15 additions & 13 deletions angular-spinner.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,25 +26,27 @@
.directive('usSpinner', ['$window', function ($window) {
return {
scope: true,
controller: ['$scope', '$element', '$attrs', function ($scope, $element, $attrs) {
$scope.spinner = null;
$scope.key = angular.isDefined($attrs.spinnerKey) ? $attrs.spinnerKey : false;
$scope.startActive = angular.isDefined($attrs.spinnerStartActive) ?
$attrs.spinnerStartActive : !($scope.key);
link: function (scope, element, attr) {
scope.spinner = null;

scope.key = angular.isDefined(attr.spinnerKey) ? attr.spinnerKey : false;

scope.startActive = angular.isDefined(attr.spinnerStartActive) ?
attr.spinnerStartActive : scope.key ?
false: true;

$scope.spin = function () {
if ($scope.spinner) {
$scope.spinner.spin($element[0]);
scope.spin = function () {
if (scope.spinner) {
scope.spinner.spin(element[0]);
}
};

$scope.stop = function () {
if ($scope.spinner) {
$scope.spinner.stop();
scope.stop = function () {
if (scope.spinner) {
scope.spinner.stop();
}
};
}],
link: function (scope, element, attr) {

scope.$watch(attr.usSpinner, function (options) {
scope.stop();
scope.spinner = new $window.Spinner(options);
Expand Down

0 comments on commit c4dae9e

Please sign in to comment.