{"id":20314337,"url":"https://github.com/normandy72/manipulating-the-dom","last_synced_at":"2026-04-14T10:31:19.175Z","repository":{"id":153902813,"uuid":"587735695","full_name":"Normandy72/Manipulating-The-DOM","owner":"Normandy72","description":"Manipulating the DOM with link in AngularJS. Coursera course \"Single Page Web Applications with AngularJS\" by Yaakov Chaikin.","archived":false,"fork":false,"pushed_at":"2023-01-11T14:44:24.000Z","size":100,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-04T08:44:56.455Z","etag":null,"topics":["angular","angularjs","css","css3","html","html5","javascript","jqlite","jquery","js"],"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/Normandy72.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-01-11T13:16:10.000Z","updated_at":"2023-01-11T14:14:32.000Z","dependencies_parsed_at":null,"dependency_job_id":"a9a4629e-3b13-4f4d-ae40-029a9ddefc70","html_url":"https://github.com/Normandy72/Manipulating-The-DOM","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/Normandy72/Manipulating-The-DOM","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Normandy72%2FManipulating-The-DOM","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Normandy72%2FManipulating-The-DOM/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Normandy72%2FManipulating-The-DOM/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Normandy72%2FManipulating-The-DOM/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Normandy72","download_url":"https://codeload.github.com/Normandy72/Manipulating-The-DOM/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Normandy72%2FManipulating-The-DOM/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31793212,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-14T02:24:21.117Z","status":"ssl_error","status_checked_at":"2026-04-14T02:24:20.627Z","response_time":153,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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":["angular","angularjs","css","css3","html","html5","javascript","jqlite","jquery","js"],"created_at":"2024-11-14T18:14:51.512Z","updated_at":"2026-04-14T10:31:19.144Z","avatar_url":"https://github.com/Normandy72.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"## Manipulating the DOM with link\n### Step 1: Declare Link Function\n```\nfunction MyDirective(){\n    var ddo = {\n        scope: {...},\n        link: linkFunction,\n        ...\n        templateUrl: 'template.html'\n    };\n    return ddo;\n}\n```\n### Step 2: Define the Link Function\n```\nfunction LinkFunction(scope, element, attrs, controller){\n    ...\n}\n```\n***\n##### _Summary_\n* DOM manipulation usually done inside of the link function declared on the DDO.\n* Link function does not support injection. To use injected components, services, inject them into directive.\n* 'scope' parameter is the exact `$scope` in directive's controller.\n* 'element' object represents the element of the directive:\n    * Top level element.\n    * It's jqLite object or jQuery object (if jQuery is included before Angular).\n***\n## Using Directive’s transclude to Wrap Other Elements\n### Step 1: Set transclude to true\n```\nfunction MyDirective(){\n    var ddo = {\n        scope: {...},\n        transclude: true,\n        ...\n        templateUrl: \"template.html\"\n    };\n    return ddo;\n}\n```\n### Step 2: Wrap Some Parent Content\n```\n\u003cmy-directive\u003e\n    \u003cspan\u003e\n        WARNING! WARNING! {{ctrl.someProp}}\n    \u003c/span\u003e\n\u003c/my-directive\u003e\n```\n`{{ctrl.someProp}}` - evaluated in the parent controller, NOT in our directive\n\n### Step 3: ng-transclude To Place Wrapper Content\n```\n\u003cdiv\u003e\n    ...\n    \u003cdiv ng-transclude\u003e\u003c/div\u003e\n\u003c/div\u003e\n```\n`\u003cdiv ng-transclude\u003e\u003c/div\u003e` - insert evaluated wrapped content into element marked with ng-transclude\n\n***\n##### _Summary_\n* `transclude` allows whole templates to be passed into a directive.\n* The wrapped content is evaluated in the parent's context, NOT in the directive's context.\n* In the DDO:\n    * transclude: true\n* In directive's template:\n    * ng-transclude attribute designates place for evaluated wrapped content.\n***","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnormandy72%2Fmanipulating-the-dom","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnormandy72%2Fmanipulating-the-dom","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnormandy72%2Fmanipulating-the-dom/lists"}