I'm facing an issue where my code is functional, but I keep encountering a Tslint error that's proving difficult to resolve. This particular configuration worked fine with Angular 1, but now I'm in the process of migrating the application to version 4 using angular-cli.
Angular: Identifier 'vin' is not defined. Object does not contain such a member.
I've stored shared Regex patterns in an object as shown below. These patterns are imported into my component and referenced using [pattern]="patterns.KEY"
.
The validation seems to be functioning correctly based on the pattern implementation, however, the aforementioned error persists whenever it's attached to any of the input fields. Could this be due to missing data types definition for the patterns
object? If so, how should it be declared?
The error specifically occurs within the template file, as neither the component nor the Patterns file show 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,
};