Is it possible to put a varible(or a const) to the path instead of writting whole path as string literal. As it seems, angular doesn't accept anything but string literal.
import aClass = require("./simpleClass");
import { aComponent } from aClass.myClass.Root + 'tutorialponent';
myClass:
export class myClass{
public static Root = "./"
}
In this example aClass.myClass.Root + 'tutorialponent'
has error which was explained
Is it possible to put a varible(or a const) to the path instead of writting whole path as string literal. As it seems, angular doesn't accept anything but string literal.
import aClass = require("./simpleClass");
import { aComponent } from aClass.myClass.Root + 'tutorial.ponent';
myClass:
export class myClass{
public static Root = "./"
}
In this example aClass.myClass.Root + 'tutorial.ponent'
has error which was explained
- "has error which is explained" what error? – evolutionxbox Commented Apr 18, 2017 at 9:39
- Compiler says that path should be literal string – Siamak Ferdos Commented Apr 18, 2017 at 9:40
-
aClass.myClass.Root
isundefined
... Instead useaClass.Root
? Although I still don't think that will work. – evolutionxbox Commented Apr 18, 2017 at 9:41
1 Answer
Reset to default 7it does support dynamic imports now..
just do this
async () => {
const { aComponent } = await import(aClass.myClass.Root + 'tutorial.ponent');
}
for more information
http://2ality./2017/01/import-operator.html
Try this
import aClass from "./simpleClass";
var aComponent = require(aClass.myClass.Root + 'tutorial.ponent').aComponent;
or
import { myClass } from './simpleClass';
const { aComponent } = require(myClass.Root + 'tutorial.ponent');