from this response add provide: NG_VALIDATORS, remove required and add a validatiton function like
public setDisabledState?(isDisabled: boolean): void { }
validate(control:any){
return this.model?null:{required:true}
}
your forked stackblitz
Update
There are a problem when we using an array of string (or an array of numbers) with [(ngModel)].
This not work
{{model.loopValues|json}}
//NOT WORK
<div *ngFor="let n of model.loopValues; let i = index;">
<input [(ngModel)]="n"
name="{{'ct'+i}}" #control="ngModel"></custom-text>
</div>
And not work because the ngModel is binding over the temporally variable "n". If model.loopValues was an array of object this work because is binding over the "memory position" of the object.
We can think about this
//NOT WORK
<div *ngFor="let n of model.loopValues; let i = index;">
<input [(ngModel)]="model.loopValues[i]"
name="{{'ct'+i}}" #control="ngModel"></custom-text>
</div>
And not work because, when we change the input, lost the focus because Angular render again the *ngFor
My Idea is in .ts has an array of the same length of the model.loopValues
array=new Array(this.model.loopValues.length)
And now we can do
<div *ngFor="let n of array; let i = index;">
<custom-text [(ngModel)]="model.loopValues[i]"
name="{{'ct'+i}}" #control="ngModel"></custom-text>
</div>
BONUS: We can use a repeat directive and write some like
<div *repeat="model.loopValues.length;let i">
<custom-text [(ngModel)]="model.loopValues[i]"
name="{{'ct'+i}}" #control="ngModel"></custom-text>
</div>