My guess would be that the constant has not been imported where you are
using it.
Where are you trying to use the constant? In a template, maybe?
One other thing, unrelated to your issue, is you have defined Hero as a
class but you initialize the constant as a generic object. You should add a
constructor to your Hero class and call "new" when creating your constant:
export const DR_EVIL = new Hero(666, 'Dr. Evil');
export class Hero {
constructor(public id: number, public name: string) {}
}
On Fri, Aug 5, 2016 at 4:51 PM, <[email protected]> wrote:
> Hi!
>
> This may be a more TypeScript related question but you may still help me.
> What I try to do is to access a Object statically. As an example, a fixed
> list of heroes:
>
>
> export const DR_EVIL: Hero = {id: 666, name: 'Dr. Evil'};
>
> export class Hero {
> id: number;
> name. string;
> }
>
> But although it compiles and I can create Hero Objects, I can't use
> DR_EVIL since it tells me it is not known.
>
> So how would someone do this in TypeScript?
>
> With best regards,
> Andreas Fagschlunger
>
> --
> You received this message because you are subscribed to the Google Groups
> "AngularJS" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> To post to this group, send email to [email protected].
> Visit this group at https://groups.google.com/group/angular.
> For more options, visit https://groups.google.com/d/optout.
>
--
Lucas Lacroix
Computer Scientist
System Technology Division, MEDITECH <http://ehr.meditech.com>
781-774-2293
--
You received this message because you are subscribed to the Google Groups
"AngularJS" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/angular.
For more options, visit https://groups.google.com/d/optout.