{"id":15649188,"url":"https://github.com/tuchk4/requirejs-angular-loader","last_synced_at":"2025-04-30T15:24:20.231Z","repository":{"id":15136985,"uuid":"17864245","full_name":"tuchk4/requirejs-angular-loader","owner":"tuchk4","description":"Provide requirejs plugins for loading angular components","archived":false,"fork":false,"pushed_at":"2015-06-01T22:01:59.000Z","size":195,"stargazers_count":40,"open_issues_count":1,"forks_count":6,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-04-30T15:24:15.900Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/tuchk4.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2014-03-18T12:05:09.000Z","updated_at":"2018-08-30T18:02:13.000Z","dependencies_parsed_at":"2022-09-11T04:41:18.735Z","dependency_job_id":null,"html_url":"https://github.com/tuchk4/requirejs-angular-loader","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tuchk4%2Frequirejs-angular-loader","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tuchk4%2Frequirejs-angular-loader/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tuchk4%2Frequirejs-angular-loader/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tuchk4%2Frequirejs-angular-loader/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/tuchk4","download_url":"https://codeload.github.com/tuchk4/requirejs-angular-loader/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":251730068,"owners_count":21634319,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-03T12:28:42.548Z","updated_at":"2025-04-30T15:24:20.201Z","avatar_url":"https://github.com/tuchk4.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"## Important\n\nI will publish node component for generation plugins according to nested structure config. It will be more flexible and powerful and do not relate to any framework. Just plugins.\n\n\n\n## Loading angular components with requirejs\n\n![alt text](http://habrastorage.org/files/db8/049/a1f/db8049a1fac64bc393eb29e52b3bb03c.png \"Application structure\")\n\nTher are 7 plugins for loading angularjs components:\n\n- module\n- template\n- controller\n- service\n- directive\n- config\n- filter\n\nThe goals: \n \n - Add module support to application. Module - means not ng module but something like \"namespace\" for controllers, directives, filters, templates etc;\n - Reduce code dependecy on application structure and module's names.\n\n\n#### Module \n\nFile that return ngModule\n\n```javascript\ndefine(function(require){\n    var ng = requrie('angular');\n\n    return ng.module('foo', []);\n})\n```\n\n#### Template\n\nThis plugin depends on requirejs text plugin. Used for loading templates.\n\n#### Controller / Service / Directive / Filter / Config\n\nSimilar goal - load components.\n\n\nExamples\n========\n\nExample application you could find here: https://github.com/tuchk4/requirejs-angular-loader-bootstrap\n\nFor example we have application with such structure:\n\n    app\n       |-modules\n       |       |-menu\n       |       |    |-controller\n       |       |    |           |-menu-controller.js\n       |       |    |-menu.js    \n       |       |-user\n       |             |-controllers\n       |             |           |-profile.js\n       |             |-resources\n       |             |          |-templates\n       |             |          |       |-user-profile.html\n       |             |          |-directives\n       |             |                   |-user-menu \n       |             |                              |-user-menu.js\n       |             |                              |-user-menu.html\n       |             |-src\n       |             |      |-providers\n       |             |      |          |-profile-information.js \n       |             |      |-factory\n       |             |              |-guest.js\n       |             |-user.js\n       |-application.js\n       |-boot.js\n\n\nWe want to include **menu** ng module (/app/modules/menu/menu) in file:\n \n  - **/app/application.js**  -  `require('module!user')`\n  - **/app/modules/user.js**  -  `require('module!user')` \n  - **/app/modules/menu/menu-controller.js**  -  `require('module!@')`. @ - say to load current module that could be detected from path of the current file.\n  \nWe want to include **user-controller** (/app/modules/user/controllers/user-controller) in file:\n \n  - **/app/application.js**  -  `require('controller!user:profile')`. Before **\":\"** - module name, after - controller name.\n  - **/app/modules/user.js** -  `require('controller!user:profile')`\n  - **/app/modules/user/user.js**  -  `require('controller!profile')`. So if you want to load controller from current module (current module I mean module under which current file is located) - you could write only controller name. Module will be detected from current path.\n  \n\nSame for **directives**, **services**, **templates**, **filters**, **configs**.\n  \n\nConfiguration\n========\n\nPlugins should be configured using placeholders in requirejs.config({...}) under structure key. \n\n```javascript\nrequirejs.config({\n  baseUrl: '/application',\n  paths: {\n    'text': '../bower_components/requirejs-text/text',\n    'base': 'plugins/base',\n    'template': 'plugins/template',\n    'controller': 'plugins/controller',\n    'service': 'plugins/service',\n    'module': 'plugins/module',\n    'config': 'plugins/config',\n    'directive': 'plugins/directive',\n    'filter': 'plugins/filter'\n  },\n  structure: {\n      /**\n       * @description\n       * requirejs.config.baseUrl + structure.prefix\n       *\n       * requirejs.config.baseUrl = '/application'\n       * structure.prefix = modules/{module}\n       * {module} - module name\n       *\n       * result:\n       *\n       * application/modules/{module}\n       */\n      prefix: 'modules/{module}',\n      \n      module: {\n        path: '/{module}'\n      },\n\n      /**\n       * @description\n       *\n       * syntax:\n       *  require('template!{module}:{template-name}');\n       *\n       *  require('template!{template-name}') - in this case - will be used current module\n       *    (which contains the current file)\n       *\n       *  require('template!@{template-name}') - same as above\n       *\n       *\n       * if current module - foo (file where you use require is located under foo's module directory\n       *  Example: /application/modules/foo/foo-include.js)\n       *  next paths are same:\n       *\n       * require('template!bar')\n       * require('template!@bar')\n       * require('template!foo:bar')\n       *\n       * We will get:\n       *\n       *  /resource/views/{template}.{extension}\n       *    -\u003e /resource/views/bar.html     \n       *   then: requirejs.config.baseUrl + module + template path\n       *   -\u003e /application/modules/foo/resource/views/bar.html\n       *\n       *    baseUrl: /application\n       *    modules dir: /modules\n       *    module name: /foo\n       *    template path: /resource/views/bar.html\n       */\n      template: {\n        path: '/resources/views/{template}.{extension}',\n        extension: 'html'\n      },\n\n      /**\n       * @description\n       *\n       * Same for controller\n       */\n      controller: {\n        path: '/controllers/{controller}'\n      },\n\n      /**\n       * @description\n       *\n       * Same for service\n       */\n      service: {\n        path: '/src/{service}'\n      },\n\n      /**\n       * @description\n       *\n       * Same for config\n       */\n      config: {\n        path: '/resources/configs/{config}'\n      },\n\n      /**\n       * @description\n       *\n       * Same for directive\n       */\n      directive: {\n        path: '/resources/directives/{directive}'\n      },\n\n      /**\n       * @description\n       *\n       * Same for filter\n       */\n      filter: {\n        path: '/resources/filter/{filter}'\n      }\n    },\n    shim: {\n      'angular': {\n        exports: 'angular'\n      },\n      'angular-route': {\n        deps: ['angular']\n      },\n      'angular-cache': {\n        deps: ['angular']\n      },\n      'angular-resource': {\n        deps: ['angular']\n      }\n    }\n});\n```\n\n//test\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftuchk4%2Frequirejs-angular-loader","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftuchk4%2Frequirejs-angular-loader","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftuchk4%2Frequirejs-angular-loader/lists"}