hino / app / components / app-navbar.js
app-navbar.js
Raw
import Component from '@ember/component';
import { inject as service } from '@ember/service';
import { computed } from '@ember/object';

export default Component.extend({
    session: service(),
    router: service(),
    currentRouteName : computed('router.currentRouteName', {
        get() {
            let currentRoute = this.get('router').get('currentRouteName');
            let currentRouteArr = currentRoute.split(".");
            currentRoute = currentRouteArr[0];
            return currentRoute;
        }
    }),
    init() {
        this._super(...arguments);
    },
    actions: {
        logout() {
            // console.log("test");
            this.get('session').invalidate();
        }
    }
});