Angular – Passing value from HTML to component does not work

  angular, data-binding, html, javascript, typescript

In my project I am trying to pass name from .html to .ts file.

In .html file I pass value to newValue method. In ts when I console.log the value of name, is displays nothing.

How can I make this work?

.ts

  newValue(name: string) {
  console.log(name); ------------------> displays nothing
  }

.html

  <dd id="{{genId(name.value)}}">
          <inline-concept-edit *ngIf="name.$new; else noValueExists" id="tane"
 [(field)]="name.value" [elementType]="record.finish"(fieldChange)="newValue(name)"></inline-concept-edit>
          <ng-template #noValueExists>
            <span *ngIf="!name.$new"
                  matTooltip="We cannot change the value"
                  [matTooltipPosition]="'right'"
                  [matTooltipDisabled]="!editMode">
              {{name.value}}
            </span>
          </ng-template>
        </dd>

Source: Angular Questions

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.