{"action":"created","issue":{"url":"https://api.github.com/repos/angular/angular.js/issues/13677","labels_url":"https://api.github.com/repos/angular/angular.js/issues/13677/labels{/name}","comments_url":"https://api.github.com/repos/angular/angular.js/issues/13677/comments","events_url":"https://api.github.com/repos/angular/angular.js/issues/13677/events","html_url":"https://github.com/angular/angular.js/issues/13677","id":124970083,"number":13677,"title":"Defining scope type explicitly in a readable way","user":{"login":"iamisti","id":4672916,"avatar_url":"https://avatars.githubusercontent.com/u/4672916?v=3","gravatar_id":"","url":"https://api.github.com/users/iamisti","html_url":"https://github.com/iamisti","followers_url":"https://api.github.com/users/iamisti/followers","following_url":"https://api.github.com/users/iamisti/following{/other_user}","gists_url":"https://api.github.com/users/iamisti/gists{/gist_id}","starred_url":"https://api.github.com/users/iamisti/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/iamisti/subscriptions","organizations_url":"https://api.github.com/users/iamisti/orgs","repos_url":"https://api.github.com/users/iamisti/repos","events_url":"https://api.github.com/users/iamisti/events{/privacy}","received_events_url":"https://api.github.com/users/iamisti/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/angular/angular.js/labels/component:%20$compile","name":"component: $compile","color":"e102d8"},{"url":"https://api.github.com/repos/angular/angular.js/labels/needs:%20feedback","name":"needs: feedback","color":"bfdadc"},{"url":"https://api.github.com/repos/angular/angular.js/labels/severity:%20confusing","name":"severity: confusing","color":"cd19e7"},{"url":"https://api.github.com/repos/angular/angular.js/labels/type:%20feature","name":"type: feature","color":"00a606"}],"state":"open","locked":false,"assignee":{"login":"gkalpak","id":8604205,"avatar_url":"https://avatars.githubusercontent.com/u/8604205?v=3","gravatar_id":"","url":"https://api.github.com/users/gkalpak","html_url":"https://github.com/gkalpak","followers_url":"https://api.github.com/users/gkalpak/followers","following_url":"https://api.github.com/users/gkalpak/following{/other_user}","gists_url":"https://api.github.com/users/gkalpak/gists{/gist_id}","starred_url":"https://api.github.com/users/gkalpak/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/gkalpak/subscriptions","organizations_url":"https://api.github.com/users/gkalpak/orgs","repos_url":"https://api.github.com/users/gkalpak/repos","events_url":"https://api.github.com/users/gkalpak/events{/privacy}","received_events_url":"https://api.github.com/users/gkalpak/received_events","type":"User","site_admin":false},"milestone":{"url":"https://api.github.com/repos/angular/angular.js/milestones/38","html_url":"https://github.com/angular/angular.js/milestones/Ice%20Box","labels_url":"https://api.github.com/repos/angular/angular.js/milestones/38/labels","id":529901,"number":38,"title":"Ice Box","description":"Milestone for valid issues and bugs that we have no aspirations on fixing any time soon because they are not affecting primary use-cases and are not aligned with our goals.","creator":{"login":"IgorMinar","id":216296,"avatar_url":"https://avatars.githubusercontent.com/u/216296?v=3","gravatar_id":"","url":"https://api.github.com/users/IgorMinar","html_url":"https://github.com/IgorMinar","followers_url":"https://api.github.com/users/IgorMinar/followers","following_url":"https://api.github.com/users/IgorMinar/following{/other_user}","gists_url":"https://api.github.com/users/IgorMinar/gists{/gist_id}","starred_url":"https://api.github.com/users/IgorMinar/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/IgorMinar/subscriptions","organizations_url":"https://api.github.com/users/IgorMinar/orgs","repos_url":"https://api.github.com/users/IgorMinar/repos","events_url":"https://api.github.com/users/IgorMinar/events{/privacy}","received_events_url":"https://api.github.com/users/IgorMinar/received_events","type":"User","site_admin":false},"open_issues":213,"closed_issues":156,"state":"open","created_at":"2014-01-08T08:19:21Z","updated_at":"2016-01-05T15:28:35Z","due_on":null,"closed_at":null},"comments":1,"created_at":"2016-01-05T13:49:24Z","updated_at":"2016-01-05T15:30:43Z","closed_at":null,"body":"Hi Guys,\r\n\r\nSorry if the following question will be stupid but I need to know something.\r\nWhen we defining scope types in our directives it can be 3 different types:\r\n - `scope: true`\r\n - `scope: false`\r\n -  `scope: {}`\r\nI'm always struggling when I need to create or just read a directive's cope definition if it's shared or prototypical inherited. Also it's not a good pattern in general neither that you have to simply pass boolean variables either to a function or a customisable parameter that can have different states.\r\n\r\nMy preferred approach would be something like this:\r\n- `scope: Scope.INHERITED`\r\n- `scope: Scope.SHARED`\r\n- `scope: {}`\r\n\r\nIn their implementation they can have the value of `true` and `false` (e.g.: it won't be a breaking change), it's just a matter of defining it and reading it.\r\n\r\nI know we don't have a global variable like `Scope`, but I'm open for any suggestion or solution that can give me more readable format. Maybe it could be `angular.Scope.INHERITED` or `angular.ScopeTypes.INHERITED`?\r\n\r\nPlease tell me if it does make sense for you and not just for me. It'd help me a lot for readability and for stop keep searching for the true/false meanings when I need to create a new directive."},"comment":{"url":"https://api.github.com/repos/angular/angular.js/issues/comments/169035302","html_url":"https://github.com/angular/angular.js/issues/13677#issuecomment-169035302","issue_url":"https://api.github.com/repos/angular/angular.js/issues/13677","id":169035302,"user":{"login":"gkalpak","id":8604205,"avatar_url":"https://avatars.githubusercontent.com/u/8604205?v=3","gravatar_id":"","url":"https://api.github.com/users/gkalpak","html_url":"https://github.com/gkalpak","followers_url":"https://api.github.com/users/gkalpak/followers","following_url":"https://api.github.com/users/gkalpak/following{/other_user}","gists_url":"https://api.github.com/users/gkalpak/gists{/gist_id}","starred_url":"https://api.github.com/users/gkalpak/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/gkalpak/subscriptions","organizations_url":"https://api.github.com/users/gkalpak/orgs","repos_url":"https://api.github.com/users/gkalpak/repos","events_url":"https://api.github.com/users/gkalpak/events{/privacy}","received_events_url":"https://api.github.com/users/gkalpak/received_events","type":"User","site_admin":false},"created_at":"2016-01-05T15:30:43Z","updated_at":"2016-01-05T15:30:43Z","body":"It's really a matter of interpretation. It's something you need to learn how to interprete (as many things in the DDO) and I don't think `Scope.INHERITED/SHARED` would be different in that respect either.\r\n\r\n--\r\nIf that helps, I think they way the `scope` property was meant to be interpreted is:\r\n\r\n> Does this directive needs a scope of it's own ?\r\n> * `false`: No, it doesn't => No scope is created. It still has access to all scopes in the view, because that is what happens anyway in Angular (independent of directives).\r\n> * `true`: Yes, it needs a scope => A new (normal) scope is created. In angular, a scope (normally) prototypally inherits from it's parent scope. (Again, nothing directive-specific here.)\r\n> * `{...}`: Yes, it needs a (special, isolate) scope with specific properties bound on it. (The rest is history...)\r\n\r\n---\r\nGiven that we can't replace the current implementation (as it would be too big of a breaking change), one could consider adding your suggestion as an alternative, but that would only add to the complexity of the DDO and the related concepts and imo do more harm than good.\r\n\r\nThat said, if it makes sense for you, you can easily create and use your own variables (either global or injected) and use them instead. E.g.:\r\n\r\n```\r\n// Top-level global\r\nvar ScopeType = {INHERITED: false, SHARED: true};\r\n// or\r\n// Global under `angular`\r\nangular.ScopeType = {INHERITED: false, SHARED: true};\r\n\r\napp.directive('fancyStuff', function fancyStuffDirective() {\r\n  // DDO\r\n  return {\r\n    scope: ScopeType.SHARED,   // or: angular.ScopeType.SHARED\r\n    ...\r\n  };\r\n});\r\n\r\n// or even as DI'ed constant\r\nangular.\r\n  module(...).\r\n  constant('ScopeType', {INHERITED: false, SHARED: true}).\r\n  directive('fancyStuff', function fancyStuffDirective(ScopeType) {\r\n    // DDO\r\n    return {\r\n      scope: ScopeType.SHARED,\r\n      ...\r\n    };\r\n  });\r\n```\r\n\r\n---\r\nI'll leave this open for a while, to see if anyone if feeling too strongly about adding something like this :)"}}