Disabling Prototype Extensions and Specifying URL Type

  • Post author:
  • Post category:EmberJS
  • Post comments:1 Comment
prototype extensions

The prototype extensions can be disabled by setting the EXTEND_PROTOTYPES flag to false. Open the config/environment.js file and set the flag in the ENV object −

ENV = {
   EmberENV: {
      EXTEND_PROTOTYPES: false
   }
}

The prototypes of JavaScript objects can be extended by Ember.js in the following ways −

  • Array − It is used to implement the Ember.Enumerable, Ember.MutableEnumerable, Ember.MutableArray and Ember.Array interfaces.
  • String − It adds some string helper methods such as camelize() (specifies the lowerCamelCase form), w() (divides string into separate units), etc.
  • Function − It is used to explain the functions as computed properties by using the property() method.

The above prototype extensions can be used in the application’s configuration file as shown below −

ENV = {
   EmberENV: {
      EXTEND_PROTOTYPES: {
         String: false,
         Array: true
      }
   }
}

Specifying URL Type

The application’s URL type can be specified by using Ember router’s four options −

  • history
  • hash
  • none
  • auto

History

This option uses HTML5 browser’s API to create the URLs. For instance, create a router called myroute1 under another router myroute which will navigate to the myroute.myroute1 route.

Router.map(function() {
   this.route('myroute', function() {
      this.route('myroute1');
   });
});

The above code is created under the app/router.js file to define the URL mappings that takes parameter as an object to create the route.

Hash

This option specifies the starting state of an application by using the anchor based URL’s which will put in sync as we move around. For instance, the above route path /#/myroute/myroute1 will navigate to the myroute.myroute1 route.

None

This option does not update the URL and set the ENV.locationType flag to none to disable the location API which does not allow browser’s URL to interact with your application.

Previous Page:-Click Here

This Post Has One Comment

Leave a Reply