copenndthagen
copenndthagen

Reputation: 50752

Ember app see hash in localhost URL

In my Ember app (based on engines), I do not see hash in the localhost URL

I did try changing locationType in environment.js

locationType: 'hash'

Though the routing & everything is working fine, I am just wondering how do I get the # in the address bar URL.

Below is my complete environment.js

/*jshint node:true*/
'use strict';

module.exports = function(environment, appConfig) {
    console.log(environment);
      var ENV = {
            modulePrefix: 'myapp-ui',
            environment: environment,
            rootURL: '/myapp/',
            locationType: 'auto',
            EmberENV: {
              FEATURES: {
                // Here you can enable experimental features on an ember canary build
                // e.g. 'with-controller': true
              },
              EXTEND_PROTOTYPES: {
                // Prevent Ember Data from overriding Date.parse.
                Date: false
              }
            },

            APP: {
              // Here you can pass flags/options to your application instance
              // when it is created
            },
            TRACKING_ENABLED: true,
            LOG_TRACKING_ENABLED: false,
            ROUTE_TRANSITION_TRACKING_ENABLED: false,
            LOG_ERROR_TRACKING: true,
            ANALYTICS_URL:"X",
            ANALYTICS_SITE_ID:0,
            STUB_MODE : false,
            SET_LOCALE : true
          };
    if (environment && environment !== 'development') {
        ENV.rootURL = "";
    }
  return ENV;
};

Upvotes: 0

Views: 363

Answers (2)

Driezzz
Driezzz

Reputation: 113

In your 'Router.js' file in the root of your app, you add these lines of code:

Router.reopen({
    location: 'hash'
});

More info on hash here: HASHLOCATION ember

Then go to localhost:4200/#/

Upvotes: 0

XYZ
XYZ

Reputation: 27387

Update your config/environment.js's locationType config option to hash and restart your Ember server.

locationType: 'hash', // inside ENV

Quote from Ember guies,

You can change this option in config/environment.js under ENV.locationType.

https://guides.emberjs.com/v2.2.0/configuring-ember/specifying-url-type/

Upvotes: 1

Related Questions