A
A
Angularity2017-03-08 00:08:12
JavaScript
Angularity, 2017-03-08 00:08:12

How to import .json data into Angular2 without HTTP?

There is an array of objects (users.json (for example, 10 user objects)). The data needs to be obtained to check for authentication.
Can't use backend(http).
There are options?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
Medin K, 2017-03-08
@medin84

If webpack, you can use require

import ...

 let testData = require('./test-users.json');

@Component({
...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question