{"id":13813252,"url":"https://github.com/cironunes/angular-off-canvas","last_synced_at":"2025-10-22T21:25:12.909Z","repository":{"id":12878742,"uuid":"15555222","full_name":"cironunes/angular-off-canvas","owner":"cironunes","description":"easily add an off-canvas navigation to your angular app","archived":true,"fork":false,"pushed_at":"2017-11-16T21:10:07.000Z","size":358,"stargazers_count":66,"open_issues_count":16,"forks_count":20,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-05-07T13:02:02.000Z","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/cironunes.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2013-12-31T18:57:24.000Z","updated_at":"2023-01-28T07:47:37.000Z","dependencies_parsed_at":"2022-08-26T07:01:43.272Z","dependency_job_id":null,"html_url":"https://github.com/cironunes/angular-off-canvas","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cironunes%2Fangular-off-canvas","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cironunes%2Fangular-off-canvas/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cironunes%2Fangular-off-canvas/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cironunes%2Fangular-off-canvas/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/cironunes","download_url":"https://codeload.github.com/cironunes/angular-off-canvas/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254239973,"owners_count":22037803,"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-08-04T04:01:09.896Z","updated_at":"2025-10-22T21:25:12.579Z","avatar_url":"https://github.com/cironunes.png","language":"JavaScript","funding_links":[],"categories":["JavaScript"],"sub_categories":[],"readme":"# angular-off-canvas \n[![Build Status](https://travis-ci.org/cironunes/angular-off-canvas.svg)](https://travis-ci.org/cironunes/angular-off-canvas) \n[![](https://david-dm.org/cironunes/angular-off-canvas/dev-status.svg)](https://david-dm.org/cironunes/angular-off-canvas#info=devDependencies\u0026view=table)\n\nAn off-canvas nav factory service for AngularJS that makes it easy to add off-canvas navs to your app.\n[Plunker demo](http://plnkr.co/edit/arcXHcQgdWiHVB2a7IXA?p=preview)\n\n## Install\n\n```shell\nbower install angular-off-canvas\n```\n\n## Usage\n1. Include the `off-canvas.js` script provided by this component into your app.\n2. *Optional:* Include the `off-canvas.css` style provided by this component into your html.\n3. Add `cn.offCanvas` as a module dependency to your app.\n\n### Typical Use\n\n\u003e app.js\n\n```javascript\nangular.module('myApp', ['cn.offCanvas']).\n\n// let's make a nav called `myOffCanvas`\nfactory('myOffCanvas', function (cnOffCanvas) {\n  return cnOffCanvas({\n    controller: 'MyOffCanvasCtrl',\n    controllerAs: 'offCanvas',\n    templateUrl: 'my-off-canvas.html'\n  });\n}).\n\n// typically you'll inject the offCanvas service into its own\n// controller so that the nav can toggle itself\ncontroller('MyOffCanvasCtrl', function (myOffCanvas) {\n  this.toggle = myOffCanvas.toggle;\n}).\n```\n\n\u003e my-off-canvas.html\n\n```html\n\u003cdiv class=\"off-canvas__nav\"\u003e\n  \u003ch3\u003eHello {{name}}\u003c/h3\u003e\n  \u003cp\u003e\u003ca href ng-click=\"offCanvas.toggle()\"\u003eClose Me\u003c/a\u003e\u003c/p\u003e\n\u003c/div\u003e\n```\n\n\u003e index.html\n\n```html\n\u003cdiv ng-app=\"myApp\" ng-controller=\"MyCtrl as ctrl\"\u003e\n  \u003ca href ng-click=\"ctrl.toggle()\"\u003eShow the modal\u003c/a\u003e\n\u003c/div\u003e\n```\n\n### Cleaning up\n\nIf you add any listeners within the nav's controller that are **outside the nav's `scope`**,\nyou should remove them with `$scope.$on('$destroy', fn () { ... })` to avoid creating a memory leak.\n\n### Inline Options\n\n**Note:** The best practice is to use a separate file for the template and a separate declaration for\nthe controller, but inlining these options might be more pragmatic for cases where the template or\ncontroller is just a couple lines.\n\n```javascript\nangular.module('myApp', ['cn.offCanvas']).\n\n// let's make a nav called myOffCanvas\nfactory('myOffCanvas', function (btfModal) {\n  return btfModal({\n    controller: function () {\n      this.name = 'World';\n    },\n    controllerAs: 'ctrl',\n    template: '\u003cdiv class=\"off-canvas__nav\"\u003eHello {{ctrl.name}}\u003c/div\u003e'\n  });\n}).\n\ncontroller('MyCtrl', function (myOffCanvas) {\n  this.toggle = myOffCanvas.toggle;\n});\n```\n\n```html\n\u003cdiv ng-app=\"myApp\" ng-controller=\"MyCtrl\"\u003e\n  \u003ca href ng-click=\"ctrl.toggle()\"\u003eToggle the nav\u003c/a\u003e\n\u003c/div\u003e\n```\n\n\n## API\n\n### `cnOffCanvas`\n\nThe nav `factory`. Takes a configuration object as a parameter:\n\n```javascript\nvar navService = cnOffCanvas({\n  /* options */\n})\n```\n\nAnd returns a `navService` object that you can use to toggle the nav (described below).\n\nThe config object **must** either have a `template` or a `templateUrl` option.\n\nThese options work just like the [route configuration in Angular's\n`$routeProvider`](http://docs.angularjs.org/api/ngRoute.$routeProvider#methods_when).\n\n\n#### `config.template`\n**string:** HTML string of the template to be used for this modal.\nUnless the template is very simple, you should probably use `config.templateUrl` instead.\n\n#### `config.templateUrl`\n**string (recommended):** URL to the HTML template to be used for this modal.\n\n#### `config.controller`\n**string|function (optional):** The name of a controller or a controller function.\n\n#### `config.controllerAs`\n**string (optional, recommended):** Makes the controller available on the scope of the modal as the given name.\n\n#### `config.container`\n**DOM Node (optional):** DOM node to prepend. Defaults to `document.body`.\n\n#### `config.containerClass`\n**string (optional):** HTML class to add to the container. Defaults to `is-off-canvas-opened`.\n\n### `navService`\n\nA `navService` has only one method: `toggle` which enable us to show/hide the nav.\n\n#### `navService.toggle`\n\nAdd or remove a class to open/hide the nav with CSS.\n\n## Contributing\n\nPlease see the [contributing guidelines](https://github.com/cironunes/angular-off-canvas/blob/master/CONTRIBUTING.md)\n\n## Tests\n\nYou can run the tests with [`karma`](http://karma-runner.github.io/0.10/index.html):\n\n```shell\nkarma start\n```\n\n\n## License\nMIT\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcironunes%2Fangular-off-canvas","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcironunes%2Fangular-off-canvas","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcironunes%2Fangular-off-canvas/lists"}