Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

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.