{"id":20314352,"url":"https://github.com/normandy72/directive-apis","last_synced_at":"2026-04-22T03:31:30.795Z","repository":{"id":153902759,"uuid":"587691751","full_name":"Normandy72/Directive-APIs","owner":"Normandy72","description":"Directive APIs and “\u0026” in AngularJS.  Coursera course \"Single Page Web Applications with AngularJS\" by Yaakov Chaikin.","archived":false,"fork":false,"pushed_at":"2023-01-11T12:27:06.000Z","size":68,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-04T08:44:55.055Z","etag":null,"topics":["angular","angularjs","html","html5","javascript","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-11T11:01:19.000Z","updated_at":"2023-01-11T12:27:09.000Z","dependencies_parsed_at":null,"dependency_job_id":"a7e96c68-ad21-4012-b273-a318dec9c91a","html_url":"https://github.com/Normandy72/Directive-APIs","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/Normandy72/Directive-APIs","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Normandy72%2FDirective-APIs","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Normandy72%2FDirective-APIs/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Normandy72%2FDirective-APIs/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Normandy72%2FDirective-APIs/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Normandy72","download_url":"https://codeload.github.com/Normandy72/Directive-APIs/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Normandy72%2FDirective-APIs/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32119717,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-22T00:31:26.853Z","status":"online","status_checked_at":"2026-04-22T02:00:05.693Z","response_time":58,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"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","html","html5","javascript","js"],"created_at":"2024-11-14T18:14:53.643Z","updated_at":"2026-04-22T03:31:30.779Z","avatar_url":"https://github.com/Normandy72.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"## Directive APIs and “\u0026”\n### Step 1: Define Method in Controller\n```\nfunction Controller(){\n    this.method = function(arg1){\n        this.prop = \"Hi\" + arg1;\n    };\n}\n```\n`this.method` - 'this' refers to parent controller instance\n\n`arg1` - 'arg1' needs to come from child directive\n\n### Step 2: Declare Method Reference in Directive\n```\nfunction MyDirective(){\n    var ddo = {\n        scope:{\n            myMethod: '\u0026method'\n        },\n        ...\n        temolateUrl: 'template.html'\n    };\n    return ddo;\n}\n```\n`myMethod` - property name to reference parent method in directive\n\n`'\u0026method'` - attribute name to use in parent temolate on this directive\n\n### Step 3: Declare In Parent's Template\n```\n\u003cdiv ng-controller=\"Controller as ctrl\"\u003e\n    \u003cmy-directive method=\"ctrl.method(myArg)\"\u003e\n    \u003c/my-directive\u003e\n\u003c/div\u003e\n```\n`.method` - reference to method in controller\n\n`(myArg)` - placeholder label for value to be passed in from directive\n\n### Step 4: Map Method \u0026 Args in Directive's Template\n```\n\u003cbutton ng-click=\"dirCtrl.myMethod({myArg : 'v1'})\"\u003e\n    Remove Item\n\u003c/button\u003e\n```\n`.myMethod` - method name from isolate scope mapping\n\n`{myArg : 'v1'}` - map of parent template declared arg name to value from directive\n\n***\n##### _Summary_\n* '\u0026' binding allows us to execute an expression (such a function value) in the context of the parent scope.\n* Parent template must declare an attribute providing:\n    * Method reference to call on the patent.\n    * Argument keys for directive to bind values to.\n* Directive:\n    * calls the referenced method;\n    * provides a map of argument key to value pairs;\n    * allows directive to pass data back to parent from isolate scope.\n***\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnormandy72%2Fdirective-apis","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnormandy72%2Fdirective-apis","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnormandy72%2Fdirective-apis/lists"}