{"id":17458150,"url":"https://github.com/pocesar/angular-save-content","last_synced_at":"2025-04-02T21:29:50.972Z","repository":{"id":26512969,"uuid":"29965706","full_name":"pocesar/angular-save-content","owner":"pocesar","description":"Save the content of a part of your server rendered HTML, so it won't issue an AJAX call to fetch the templateUrl","archived":false,"fork":false,"pushed_at":"2015-01-28T12:23:19.000Z","size":124,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2024-10-18T06:28:39.413Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","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/pocesar.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":"2015-01-28T12:05:13.000Z","updated_at":"2015-01-28T12:23:19.000Z","dependencies_parsed_at":"2022-09-14T07:00:33.038Z","dependency_job_id":null,"html_url":"https://github.com/pocesar/angular-save-content","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/pocesar%2Fangular-save-content","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pocesar%2Fangular-save-content/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pocesar%2Fangular-save-content/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pocesar%2Fangular-save-content/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/pocesar","download_url":"https://codeload.github.com/pocesar/angular-save-content/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246895502,"owners_count":20851281,"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-18T03:55:31.689Z","updated_at":"2025-04-02T21:29:50.943Z","avatar_url":"https://github.com/pocesar.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# angular-save-content\n\nA directive that will save the content of a part of your server rendered HTML, so it won't issue an AJAX call to fetch the templateUrl along side ui-view or ng-view\n\n## Usage\n\n```js\nangular\n.module('yourapp', ['saveContent'])\n.config(['$stateProvider', function($stateProvider){\n  $stateProvider.state('index', {\n    url: '/',\n    templateUrl: 'template.html'\n  });\n});\n```\n\n```html\n\u003cdiv ui-view save-content=\"template.html\"\u003e\n  \u003cdiv\u003eHi, I was rendered at page load on the server and will stick around while the router path doesn't change\u003c/div\u003e\n\u003c/div\u003e\n```\n\nThis will save the inner HTML of the ui-view to `$templateCache` as `template.html`, saving you another round-trip to the server\n\nYou can save multiple snippets of already HTML placed on the page, instead of relying on `\u003cscript type=\"text/ng-template\" id=\"template.html\"\u003e` like menus, asides, widgets that were rendered when the page loaded.\n\n## Why?\n\nWhen using ng-view, ui-view along with templateUrl or ng-include, angular will issue an AJAX call to fetch the content for that view. When you are creating an hybrid page, that mix 'turbo links', many SPA views and server rendered content, you'll end up with the first load of the page already loaded inside ng-view / ui-view, so you don't need it for fetchin g the content that is already visible on the page, and usually refetching it will cause a flicker. So you save the content you already have to the templateCache, so it won't create another get request to the server.\n\n## License\n\nMIT\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpocesar%2Fangular-save-content","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpocesar%2Fangular-save-content","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpocesar%2Fangular-save-content/lists"}