Reputation: 1678
I'm trying to implement ngx-translate from this tutorial:
Locally when I run the angular app using npm start it's working fine. But when I want to use custom subdir like this: ng build --output-path angular --base-href=/angular/
and to deploy it on Apache server the file is not found.
File is located under src\assets\i18n\en.json
I get multiple errors like this:
message: "Http failure response for http://123.123.123.123/assets/i18n/en.json: 404 Not Found"
With some luck I managed to solve this using this code:
export function HttpLoaderFactory(httpClient: HttpClient) {
return new TranslateHttpLoader(httpClient, '/angular/assets/i18n/', '.json');
}
But now when I run locally using ng start
the files is not found.
Do you know how this can be fixed in both cases?
Upvotes: 1
Views: 350
Reputation: 2397
you must change in relative path
export function HttpLoaderFactory(httpClient: HttpClient) {
return new TranslateHttpLoader(httpClient, 'assets/i18n/', '.json');
}
Upvotes: 1