Look at Object.freeze, which is part of es6. Just keep in mind that this
won't work and can't be polyfilled on older browsers.

On Sat, Aug 6, 2016, 15:27 <[email protected]> wrote:

> Hello Lucas!
>
> Yes, I've missed to import the constant...
>
> import { Hero, DR_EVIL } from './hero.model';
>
> And in that moment I realized, I want something like Hero.DR_EVIL.
>
> So my class looks like this now:
>
> export class Hero {
>     public static DR_EVIL = new Hero(666, 'Dr. Evil');
>
>     constructor(public id: number, public name: string) {}
> }
>
> It works fine, but another question I have is: How do I make this Object
> immutable?
>
>
>
> --
> 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.
>

-- 
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.

Reply via email to