What's the difference between establishing a class and an interface in angular?

What"s the difference between creating a class and an interface in

angular? What"s the difference between
defining variables in constructor?

export class Hero {
id: number;
name: string;
}

export class Hero {
constructor (

)
public id: number,
public name: string) { }

}

Thank you

Feb.26,2021

interface Person {
    name: string;
    age: number;
}

class Zhangsan implements Person {

}

class Zhangsan {
    name: string;
    age: number;
}

probably means that interface extracts public properties and methods, and class is a specific object


interface just provides a declaration describing what your object looks like, and cannot instantiate
class is to describe what your object looks like

constructor(

public id: number,
public name: string) { }

automatically declares class properties id and name, and automatically assigns values in the constructor


interface is the interface used to standardize class


the class, used by the official demo is supposed to use interface, right? What is particular about

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1e98ec1-4645b.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1e98ec1-4645b.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?