I'm having an issue where the code is working but I'm getting a Tslint error that I can't figure out. This setup worked when using Angular 1 but now I'm converting the application to 4 using angular-cli.
Angular: Identifier 'vin' is not defined. Object does not contain such a member.
I have shared Regex patterns stored in an Object shown below. It gets imported into my component and is then called using [pattern]="patterns.KEY".
The pattern works just like it should and validation is working but I'm still getting the above error when I attach it to any of my inputs. Is it because I'm missing data types on patterns? If so, how would it be defined?
The error is only thrown on the template file. The component and Patterns file do not have any validation errors.
Template Code:
<div class="form-group">
<label for="vin">VIN</label>
<input type="text" class="form-control" id="vin" placeholder="VIN"
minlength="8" maxlength="17" required [pattern]="patterns.vin"
[(ngModel)]="model.Vin" name="Vin" #Vin="ngModel">
</div>
Component code:
export class COMPONENT_NAME implements OnInit {
patterns = Patterns;
}
Patterns file:
export const Patterns: Object = {
vin: /^[\w\d]+$/i,
};