[英]problem in defining empty list of a class in angular 12
i have a problem defining a empty list of a class in angular.this is my class我在定义 angular 中的 class 的空列表时遇到问题。这是我的 class
export class category{
public Id:number;
public Name:string;
constructor(
){}}
i got this error.我得到了这个错误。
An element access expression should take an argument元素访问表达式应该带一个参数
any help will be highly appreciated任何帮助将不胜感激
You got this error because you are trying to declare your variable after import statements, not into the class.你得到这个错误是因为你试图在 import 语句之后声明你的变量,而不是 class。
You should declare it as below:您应该将其声明如下:
//import statements
@Component({
selector: "app-root",
templateUrl: "./app.component.html",
styleUrls: ["./app.component.css"],
})
export class AppComponent {
category: category[] = [];
constructor() {}
ngOnInit() {}
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.