Skip to content
This repository has been archived by the owner on Jan 29, 2024. It is now read-only.

Commit

Permalink
feat(directive): add $translateProvider.directityPriority
Browse files Browse the repository at this point in the history
Relates #886
  • Loading branch information
knalli committed Feb 8, 2015
1 parent faebe19 commit b0b7716
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 1 deletion.
1 change: 1 addition & 0 deletions src/directive/translate.js
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ angular.module('pascalprecht.translate')
return {
restrict: 'AE',
scope: true,
priority: $translate.directivePriority(),
compile: function (tElement, tAttr) {

var translateValuesExist = (tAttr.translateValues) ?
Expand Down
30 changes: 29 additions & 1 deletion src/service/translate.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@ angular.module('pascalprecht.translate').provider('$translate', ['$STORAGE_KEY',
$notFoundIndicatorRight,
$postCompilingEnabled = false,
NESTED_OBJECT_DELIMITER = '.',
loaderCache;
loaderCache,
directivePriority = 0;

var version = 'x.y.z';

Expand Down Expand Up @@ -761,6 +762,28 @@ angular.module('pascalprecht.translate').provider('$translate', ['$STORAGE_KEY',
return this;
};

/**
* @ngdoc function
* @name pascalprecht.translate.$translateProvider#directivePriority
* @methodOf pascalprecht.translate.$translateProvider
*
* @description
* Sets the default priority of the translate directive. The standard value is `0`.
* Calling this function without an argument will return the current value.
*
* @param {number} priority for the translate-directive
*/
this.directivePriority = function (priority) {
if (priority === undefined) {
// getter
return directivePriority;
} else {
// setter with chaining
directivePriority = priority;
return this;
}
};

/**
* @ngdoc object
* @name pascalprecht.translate.$translate
Expand Down Expand Up @@ -1757,6 +1780,11 @@ angular.module('pascalprecht.translate').provider('$translate', ['$STORAGE_KEY',
return loaderCache;
};

// internal purpose only
$translate.directivePriority = function () {
return directivePriority;
};

if ($loaderFactory) {

// If at least one async loader is defined and there are no
Expand Down

0 comments on commit b0b7716

Please sign in to comment.