Nemanja Andric
Nemanja Andric

Reputation: 665

Angular cannot assign var because is not a variable

I have a variable like this:

export var navigation = [
];

Import variable for use:

import { navigation } from 'app/navigation/navigation';

But when I want to use this variable a have the next error:

enter image description here

Upvotes: 1

Views: 3186

Answers (2)

Mateusz Wyczawski
Mateusz Wyczawski

Reputation: 96

You cannot assign data to exported values. They are read-only. When you import { navigation } from 'app/navigation/navigation'; you cannot assign any value to navigation. You can only use it to display/use some data. If you want to assign value to the navigator use other approach, eg. use service.

Upvotes: 4

SeleM
SeleM

Reputation: 9658

var navigation = [];
export default navigation;

and then :

import navigation from 'app/navigation/navigation';

Upvotes: 1

Related Questions