I am getting the following error:
Failed to execute 'setAttribute' on 'Element': ']' is not a valid attribute name.
I simply made model:
export interface ModalComponentModel {
    username: string;
    password: string;
    password2: string;
    description: string;
}
I used it in my component:
component:
model: ModalComponentModel;
Then I tried to use it in my html file:
    <div class="modal-header">
    <h4 class="modal-title text-center">Edit Profile</h4>
    <button type="button" class="close" aria-label="Close" (click)="activeModal.dismiss('Cross click')">
        <span aria-hidden="true">×</span>
    </button>
</div>
<div class="modal-body">
    <div class="row">
        <div class="col-md-2 col-md-offset-2">
            <form class="form" role="form" (ngSubmit)="whatDoesThisFormDo()">
                <div class="form-group">
                    <label for="username">Username</label>
                    <input type="text" class="form-control" name="username" id="username" placeholder="Your username"
                           [(ngModel)]="model.username">
                </div>
                <div class="form-group">
                    <label for="password1">Password</label>
                    <input type="password" class="form-control" name="password1" id="password1" placeholder="Your password"
                           [(ngModel)]="model.password">
                </div>
                <div class="form-group">
                    <label for="password2">Confirm Password</label>
                    <input type="password" class="form-control" name="password2" id="password2" placeholder="Your password"
                           [(ngModel)]="model.password2">
                </div>
                <div class="form-group">
                    <textarea rows="4" cols="50" placeholder="Description" [(ngModel)]="model.description"]></textarea>
                </div>
                <div class="row">
                    <div class="col-xs-1">
                        <button value="update" type="button" class="btn btn-primary pull-left">Update</button>
                    </div>
                    <div class="col-xs-1">
                        <button value="cancel" type="button" class="btn btn-primary pull-left">Cancel</button>
                        <div class="clear"></div>
                    </div>
                </div>
            </form>
        </div>
    </div>
</div>
<div class="modal-footer">
    <button type="button" class="btn btn-outline-dark" (click)="activeModal.close('Close click')">Close</button>
</div>
It was working fine until I added to model, full HTML is above as requested.
I am also not able to get the buttons correctly side by side.
[(ngModel)]="model.description"]      // ']' is added unnecessarily
change it to
[(ngModel)]="model.description"
Don't wrap it to a square bracket.
Update:
You can initialize your model variable as follow according to your need,
model:ModalComponentModel=<ModalComponentModel>{};
OR
model:ModalComponentModel=<ModalComponentModel>[];
                        Problem is in this line
Change
From
  <textarea rows="4" cols="50" placeholder="Description" [(ngModel)]="model.description"]></textarea>
to
  <textarea rows="4" cols="50" placeholder="Description" [(ngModel)]="model.description"></textarea>
                        You have problem in this line of code:
<textarea rows="4" cols="50" placeholder="Description" [(ngModel)]="model.description"]></textarea>
It should be:
<textarea rows="4" cols="50" placeholder="Description" [(ngModel)]="model.description"></textarea>
There is an extra bracket that is causing this error.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With