Eliya Cohen Eliya Cohen - 4 months ago 29
AngularJS Question

Angular 2 export property which is string or null

Let's say I have a property that can be a String or NULL. So I thought about doing this in Angular 2:

export class Slide {
...
link: string|null;
...
}


and then I get an error which says


Type expected.


So, how can I tell Angular that my
link
property can be either String or NULL?

Answer

link: string; is sufficient.

You can always store null in a property, whatever its type is.

Comments