Here i have classes file
export class Emp{
EmpId:number;
EmpName:String,
EmpSal:string
}
How can i wrote static object Like EmpId=1,EmpNamw=john,Empsal=200 EmpId=2,EmpName=smith,EmpSal=300
Here i have classes file
export class Emp{
EmpId:number;
EmpName:String,
EmpSal:string
}
How can i wrote static object Like EmpId=1,EmpNamw=john,Empsal=200 EmpId=2,EmpName=smith,EmpSal=300
Typescript doesn't work like that. Its module based. You should export a let or const
in your case it would be
export let Emp = {
EmpId: 2,
EmpName: 'Bla',
EmpSal: 'Bla',
}
I used an interface to create a list of Emp objects and JSON.stringify to get them as a JSON string (you can see the result in the jsfiddle).
I guess you try to do something like this:
interface IEmp{
EmpId:number;
EmpName:string;
EmpSal:string;
}
let emp1 : IEmp = {EmpId:1, EmpName:'name1', EmpSal:'sal1'};
let emp2 : IEmp = {EmpId:2, EmpName:'name2', EmpSal:'sal2'};
let lstEmp : Array<IEmp> = [emp1, emp2];
document.body.innerHTML = JSON.stringify(lstEmp);