angularjsangularangular-template

Error occurs in the template of component upperCaseComponent


It shows an error with the template,

Errors:

my html

<input type="text" [(ngModel)]="mymessage"
<button (click)="clickMe()"> send</button>
<br><br>
<h1>{{result | json}}</h1>

my component.ts

import {Component} from "@angular/core";
export class MyComponent {
private result: any;
constructor()
}

Solution

  • So here the error say it not able to find variable 'mymessage' in uppercase.component.ts

    export class UpperCaseComponent {
     public results: any; // Change it private to public
     public mymessage: any;
    }
    

    If you are trying to access variable within template you need to declare it as public as if you declare it as private it would be accessible only within class