Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Make numFixed configurable
  • Loading branch information
schinken committed Jul 6, 2016
commit d427a0926d911119cef1df77e7003f23d043d232
16 changes: 14 additions & 2 deletions src/numberDirective.js
Original file line number Diff line number Diff line change
Expand Up @@ -273,6 +273,7 @@
function createPropertyObject(scope, key, value) {
var properties = {
awnum: scope.awnum,
numFixed: scope.numFixed,
numInt: scope.numInt,
numFract: scope.numFract,
numSep: scope.numSep,
Expand All @@ -296,6 +297,7 @@
strategy = dynamicNumberStrategy.getStrategy(properties.awnum);
}
var integerPart = initIntegerPart(properties.numInt !== undefined ? properties.numInt : strategy.numInt, 6);
var isFixed = initIsFixed(properties.numFixed !== undefined ? properties.numFixed : strategy.numFixed, false);
var fractionPart = initFractionPart(properties.numFract !== undefined ? properties.numFract : strategy.numFract, 2);
var fractionSeparator = initSeparator(properties.numSep !== undefined ? properties.numSep : strategy.numSep, '.');
var isPositiveNumber = initIsPositive(properties.numPos !== undefined ? properties.numPos : strategy.numPos, true);
Expand All @@ -314,6 +316,7 @@
attrs: attrs,
ngModelController: ngModelController,
viewRegexTest: viewRegexTest,
isFixed: isFixed,
integerPart: integerPart,
fractionPart: fractionPart,
fractionSeparator: fractionSeparator,
Expand Down Expand Up @@ -444,7 +447,7 @@
initObject.fractionPart,
initObject.fractionSeparator,
initObject.roundFunction,
false,
initObject.isFixed,
initObject.isThousandSeparator,
initObject.thousandSeparator,
initObject.prepend,
Expand All @@ -459,6 +462,7 @@
require: '?ngModel',
scope: {
awnum: "@",
numFixed: "@",
numInt: "@",
numFract: "@",
numSep: "@",
Expand Down Expand Up @@ -491,6 +495,14 @@
wasPasted = true;
});

scope.$watch('numFixed', function(newProperty, oldProperty ){
if(oldProperty === newProperty) {
return;
}
initObject = initAllProperties(createPropertyObject(scope, 'numFixed', newProperty), element, attrs, ngModelController, dynamicNumberStrategy);
onPropertyWatch(ngModelController, initObject);
});

scope.$watch('numInt', function(newProperty, oldProperty ){
if(oldProperty === newProperty) {
return;
Expand Down Expand Up @@ -575,7 +587,7 @@
initObject.fractionPart,
initObject.fractionSeparator,
initObject.roundFunction,
false,
initObject.isFixed,
initObject.isThousandSeparator,
initObject.thousandSeparator,
initObject.prepend,
Expand Down