Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- angular.module('SettingsProvider', [])
- .provider('settings', [function () {
- /**
- * Templates paths
- */
- this.templates = new function () {
- this.root = '/js/application/templates';
- this.component = `${this.root}/components`;
- this.header = `${this.component}/headers`;
- this.footer = `${this.component}/footers`;
- };
- /**
- * Generate Router object
- *
- * @param type
- * @param name
- * @param controllerName
- * @returns {{templateUrl: string, controller: *}}
- */
- this.generateRouter = function (type, name, controllerName) {
- let controllerExists = typeof window[controllerName] === 'function',
- template = {};
- template.templateUrl = `${this.templates[type]}/${name}.html`;
- if (controllerExists) {
- template.controller = `${controllerName}Controller`;
- }
- console.log(`Rendering ${type} ${name}`);
- return template;
- };
- this.$get = function () {
- return this;
- };
- }]);
Advertisement
Add Comment
Please, Sign In to add comment