Generator-jhipster: Update to Angular 5

Created on 1 Nov 2017  路  4Comments  路  Source: jhipster/generator-jhipster

Most helpful comment

All 4 comments

To upgrade to angular 5 I propose to remove ng2-webstorage dependency. So you do not have to wait to update that library which seems it is not maintained.
The next step is to use the last ngx-translate which has been upgraded in September.

Very easy to remove ng2-webstorage dependency.
The only required change is rewrite state-storage.service.ts. (and remove dependencies in code)

import { Injectable } from '@angular/core';

@Injectable()
export class StateStorageService {
    constructor() {}

    getPreviousState() {
        return JSON.parse(sessionStorage.getItem('previousState'));
    }

    resetPreviousState() {
        sessionStorage.removeItem('previousState');
    }

    storePreviousState(previousStateName, previousStateParams) {
        const previousState = { 'name': previousStateName, 'params': previousStateParams };
        sessionStorage.setItem('previousState', JSON.stringify(previousState));
    }

    getDestinationState() {
        return JSON.parse(sessionStorage.getItem('destinationState'));
    }

    storeUrl(url: string) {
        sessionStorage.setItem('previousUrl', url);
    }

    getUrl() {
        return sessionStorage.getItem('previousUrl');
    }

    storeDestinationState(destinationState, destinationStateParams, fromState) {
        const destinationInfo = {
            'destination': {
                'name': destinationState.name,
                'data': destinationState.data,
            },
            'params': destinationStateParams,
            'from': {
                'name': fromState.name,
            }
        };
        sessionStorage.setItem('destinationState', JSON.stringify(destinationInfo));
    }
}

Edit:
Another required change is in webpack.common.js (https://github.com/angular/angular/issues/11580#issuecomment-327338189)

new webpack.ContextReplacementPlugin(
                /(.+)?angular(\\|\/)core(.+)?/,               
                utils.root('src/main/webapp/app'), {}
            ),

Hi,

I began the work on https://github.com/Tcharl/generator-jhipster/tree/6632.
I used a fixed artifact for web-storage, so it's not so good, but at least it works.
It now complains about ngx-translate using opaque token.
Unfortunately, I'm not an Angular Guru, nor know how to use translate well, and I'm now very busy at work so I won't be able to work on it this week (and I can't really tell when).
Feel free to start a branch from my work (It's just the dumb search and replace thing, but it's about 3 hours of work saved).

Regards,

closed by #6789

Was this page helpful?
0 / 5 - 0 ratings

Related issues

Steven-Garcia picture Steven-Garcia  路  3Comments

frantzynicolas picture frantzynicolas  路  3Comments

ahmedeldeeb25 picture ahmedeldeeb25  路  3Comments

DanielFran picture DanielFran  路  3Comments

edvjacek picture edvjacek  路  3Comments