{"id":18071337,"url":"https://github.com/kelp404/poi-router","last_synced_at":"2025-04-05T17:27:09.455Z","repository":{"id":57326745,"uuid":"52589172","full_name":"kelp404/poi-router","owner":"kelp404","description":"An AngularJS router.","archived":false,"fork":false,"pushed_at":"2020-06-18T14:41:48.000Z","size":52,"stargazers_count":2,"open_issues_count":1,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-02T20:57:00.130Z","etag":null,"topics":["angularjs","coffeescript","router"],"latest_commit_sha":null,"homepage":"https://kelp404.github.io/poi-router/","language":"CoffeeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/kelp404.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2016-02-26T08:12:30.000Z","updated_at":"2023-03-08T16:33:54.000Z","dependencies_parsed_at":"2022-09-21T01:50:23.168Z","dependency_job_id":null,"html_url":"https://github.com/kelp404/poi-router","commit_stats":null,"previous_names":[],"tags_count":9,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kelp404%2Fpoi-router","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kelp404%2Fpoi-router/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kelp404%2Fpoi-router/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kelp404%2Fpoi-router/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/kelp404","download_url":"https://codeload.github.com/kelp404/poi-router/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247372097,"owners_count":20928336,"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":["angularjs","coffeescript","router"],"created_at":"2024-10-31T09:14:53.959Z","updated_at":"2025-04-05T17:27:09.410Z","avatar_url":"https://github.com/kelp404.png","language":"CoffeeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# poi-router [![circle-ci](https://circleci.com/gh/kelp404/poi-router.png?circle-token=dfe6244905a9da85d07bf56f2190d8e74b0b30c5)](https://circleci.com/gh/kelp404/poi-router)\n\nAn AngularJS 1.X router.\n\n\n## Installation\n**bower**\n```bash\n$ bower install poi-router -S\n```\n**npm**\n```bash\n$ npm install poi-router --save\n```\n\n\n## Quick start\n**Include poi-router.js at your html**\n```html\n\u003cscript type=\"text/javascript\" src=\"/bower_components/poi-router/dist/poi-router.js\"\u003e\u003c/script\u003e\n```\n\n**Add poi-view element at the base html**\n```html\n\u003cdiv poi-view\u003e\n    \u003cp style=\"padding: 20px 0; text-align: center;\"\u003eLoading...\u003c/p\u003e\n\u003c/div\u003e\n```\n\n**Register router rules**\n```coffee\nangular.module 'your-module.routers', ['poi']\n\n.config ['$routerProvider', ($routerProvider) -\u003e\n    $routerProvider.register 'index',\n        uri: '/'\n        resolve:\n            data: ['$http', ($http) -\u003e\n                $http(method: 'get', url: '/api/data').then (response) -\u003e\n                    response.data\n            ]\n        templateUrl: '/template/index.html'\n        controller: ['$scope', 'data', ($scope, data) -\u003e\n            $scope.data = data\n        ]\n]\n```\n\n\n## Development\n```bash\n# Install node modules.\n$ npm install -g grunt-cli coffee-script nodemon\n$ npm install\n```\n\n```bash\n# Build\n$ grunt build\n```\n\n```bash\n# Test\n$ npm test\n```\n\n\n## $router\n```coffee\n$routerProvider.register = (namespace, args={})-\u003e\n    ###\n    Register the router rule.\n    @param namespace {string} The name of the rule.\n    @param args {object} The router rule.\n        abstract: {bool} This is abstract rule, it will render the child rule.\n        uri: {string}  ex: '/projects/{projectId:[\\w-]{20}}/tests/{testId:(?:[\\w-]{20}|initial)}'\n        resolve: {object}\n        templateUrl: {string}\n        controller: {string|function} The controller name or angular function.\n        onEnter: {function} It will be executed before the controller.\n    ###\n```\n\n```coffee\n$router.go = (namespace, params, options={}) -\u003e\n    ###\n    Go to the url.\n    @param namespace {string} The namespace of the rule or the url.\n    @param params {object} The params of the rule.\n    @param options {object}\n        replace: {bool}\n        reload: {bool}  If it is true, it will reload all views.\n    ###\n```\n\n```coffee\n$router.reload = (reloadParents) -\u003e\n    ###\n    Reload the current rule.\n    This method will not reload parent views if reloadParents is null.\n    @param reloadParents {bool|null}\n    ###\n```\n\n\n## Events\n**$stateChangeStart**\n```coffee\n$scope.$on '$stateChangeStart', (event, toState, fromState, cancel) -\u003e\n    ###\n    @param event {Event}\n    @param toState {object}\n        name: {string} The rule name.\n        params: {object}\n    @param fromState {object}\n        name: {string} The rule name.\n        params: {object}\n    @param cancel {function} Call this function to cancel this state change.\n    ###\n```\n\n**$stateChangeSuccess**\n```coffee\n$scope.$on '$stateChangeSuccess', (event, toState, fromState) -\u003e\n    ###\n    @param event {Event}\n    @param toState {object}\n        name: {string} The rule name.\n        params: {object}\n    @param fromState {object}\n        name: {string} The rule name.\n        params: {object}\n    ###\n```\n\n**$stateChangeError**\n```coffee\n$scope.$on '$stateChangeError', (event, error) -\u003e\n    ###\n    @param event {Event}\n    @param error {object}\n    ###\n```\n\n\n## Example\n```coffee\n# ---------------------------------------------------------\n#\n# ---------------------------------------------------------\n$routerProvider.register 'web',\n    uri: ''\n    resolve:\n        stores: ['$rootScope', '$admin', ($rootScope, $admin) -\u003e\n            $admin.api.store.getMyStores().then (response) -\u003e\n                response.data\n        ]\n    templateUrl: '/views/layout.html'\n    controller: ['$scope', 'stores', ($scope, stores) -\u003e\n        $scope.stores = stores\n    ]\n# ---------------------------------------------------------\n# /stores/:storeId\n# ---------------------------------------------------------\n$routerProvider.register 'web.store',\n    abstract: yes\n    uri: '/stores/{storeId:[\\\\w-]{20}}'\n    resolve:\n        store: ['$admin', '$rootScope', 'params', ($admin, $rootScope, params) -\u003e\n            $admin.api.store.getStore params.storeId\n            .success (store) -\u003e\n                $rootScope.$title = store.title\n            .then (response) -\u003e\n                response.data\n        ]\n    templateUrl: '/views/stores/store.html'\n    controller: 'StoreController'\n$routerProvider.register 'web.store.status',\n    uri: ''\n    onEnter: ['$rootScope', 'store', ($rootScope, store) -\u003e\n        $rootScope.$title = \"Status - #{store.title}\"\n    ]\n    templateUrl: '/views/stores/status.html'\n    controller: 'StoreStatusController'\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkelp404%2Fpoi-router","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkelp404%2Fpoi-router","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkelp404%2Fpoi-router/lists"}