1
I’m having trouble migrating from Ionic beta.11 to RC0. Every time I put a constructor waiting for type "any" I get the following error.
Ngc error: Error: Error at /Projeto/. tmp/app/app.module.ngfactory.ts:456:134: Property 'any' does not exist on type 'typeof "/Project/. tmp/Directives/Mask"'.
When going on app.module.ngfactory.ts on line 456 it generates the line below:
if ((this.__MaskDirective_75 == (null as any))) { (this.__MaskDirective_75 = new import45.MaskDirective(this.parent.get(import45.any),this.parent.get('mask'))); }
Follow the code of my directive:
import {Directive, Attribute} from '@angular/core';
@Directive({
selector: '[mask]',
host: {
'(keyup)': 'onInputChange()'
}
})
export class MaskDirective {
maskPattern: string;
placeHolderCounts: number;
dividers: string[];
modelValue: string;
viewValue: string;
constructor(
public model: any,
@Attribute("mask") maskPattern: string
) {
this.dividers = maskPattern.replace(/\*/g, "").split("");
this.dividers.push(" ");
this.generatePattern(maskPattern);
}
onInputChange() {
this.modelValue = this.getModelValue();
var stringToFormat = this.modelValue;
if (stringToFormat.length < 10) {
stringToFormat = this.padString(stringToFormat);
}
this.viewValue = this.format(stringToFormat);
this.model.viewToModelUpdate(this.modelValue);
this.model.valueAccessor.writeValue(this.viewValue)
}
generatePattern(patternString) {
this.placeHolderCounts = (patternString.match(/\*/g) || []).length;
for (let i = 0; i < this.placeHolderCounts; i++) {
patternString = patternString.replace('*', "{" + i + "}");
}
this.maskPattern = patternString;
}
format(s) {
var formattedString = this.maskPattern;
for (let i = 0; i < this.placeHolderCounts; i++) {
formattedString = formattedString.replace("{" + i + "}", s.charAt(i));
}
return formattedString;
}
padString(s) {
var pad = " ";
return (s + pad).substring(0, pad.length);
}
getModelValue() {
var modelValue = this.model.value;
for (var i = 0; i < this.dividers.length; i++) {
while (modelValue.indexOf(this.dividers[i]) > -1) {
modelValue = modelValue.replace(this.dividers[i], "");
}
}
return modelValue;
}
}
What I can do to fix this issue and continue updating my project?