Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

JavaScript AngularJS An Introduction to Directives Understanding $scope

Tom Reddish
Tom Reddish
1,320 Points

What is the point of using an isolate scope? Why not just pass through the entire scope instead of a specific part of it

He uses the isolate scope on the div in this video to only pass through the "person" object into the $scope.contact property. Why not just ignore the isolate scope and pass through the entire scope which would have the person object?

1 Answer

Igor Yamshchykov
Igor Yamshchykov
24,397 Points

using isolated scope you can't harm the data from other scope object. You also may want to change only one parent scope property and have some kind of dependencies. For instance you have variables i,j,k on parent scope and you want your directive to change only the one named 'i', but in order to change 'i' you need to modify 'j' and 'k' in your directive and don't want those changes apply to the parent scope, so in that case you might need isolated scope. Hope that make sense.