4 ms·
I really enjoyed your post. I agree that it's a good "directive smell" if your directive is reusable and application-agnostic. In that vein, I think you're ri
by cjcenizal 13y ago
I really enjoyed your post. I agree that it's a good "directive smell" if your directive is reusable and application-agnostic.
In that vein, I think you're right that an isolate scope is generally a better default because it makes it clear that the directive expects no dependencies on the inherited scope, and it prevents the directive from overwriting any scope properties set by an ancestor.
I think using an inherited scope makes sense if you're building very app-specific directives that are tightly-coupled to their ancestor.
- mortalapeman 13y agoA single element cannot have more than once isolated scope. It only makes sense to use an isolated scope when a directive has a template associated with it. Otherwise, one should rely on the $parse + the "attrs" object + $scope.$watch to correctly handle expressions.
- embwbam 13y agoThat seems strange. What happens if two attribute directives ask for an isolate scope? Does it give them the same one, or just fail? I used isolate scopes in the article because I thought they were easier to understand, but I'm thinking of updating it.
- embwbam 13y agoAfter looking into it, angular seems to throw an error if two directives ask for an isolate scope.