Tag Archives: configuration

Web

Application configuration in AngularJS

angcfg
If you are developing angular web-application, you ask how to involve configuration in it. I propose next pattern: create constant service and inject it in your other modules, services etc.
About constant in AngularJS.

1. Create app module as app.js file:

var app = angular.module('app', []);

2. Define constant service as config.js file:

app.constant('config', {
    apiUrl: 'http://localhost/api/v1',
});

3. Get your service with injected config as services.js file:

app.factory('userService', ['$http', 'config',
    function ($http, config) {
        return {
            register: function (email, password) {
                return $http({
                    url: config.apiUrl + '/user',
                    method: 'POST',
                    data: {
                        'Email': email,
                        'Password': password
                    }
                });
            },
            login: function (email, password) {
                return $http({
                    url: config.apiUrl + '/auth',
                    method: 'POST',
                    data: {
                        'Email': email,
                        'Password': password
                    }
                });
            },
            logout: function () {
                return $http({
                    url: config.apiUrl + '/auth',
                    method: 'DELETE'
                });
            },
            checkAuth: function () {
                return $http({
                    url: config.apiUrl + '/auth',
                    method: 'GET'
                });
            }
        };
}]);

So, config service is a singleton can be injected in any other services, modules etc.

Firefox home page opening in new tab configuration

4g15jq
To configure the firefox browser to open home page when new tab is opening, use next:

1. Type about:config in address bar.
Confirm next dialog:
ff_set_confirm
2. Add new string property (if not exists): browser.startup.homepage with value of your page.
3. Add new string property (if not exists): browser.newtab.url with value of your page.
The default valus is about:newtab

So, you’ll see next:
ff_set

Thats’s all!