Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

what is scope.$new(true) and how does it work

Tags:

angularjs

I am trying to test a directive ( you can see full details at: Unit testing angular directive - very stuck)

One of the things I am stuck on is finding out what scope.$new(true) means. From what I can find out it looks like $new creates a new child scope, but what is the (true) part and does angular do this automaticly because its not in my code yet it is still being thrown as the error TypeError: 'undefined' is not a function (evaluating 'scope.$new(true)')

like image 952
ReganPerkins Avatar asked Jan 28 '15 21:01

ReganPerkins


1 Answers

According to the docs, the boolean argument to Scope.$new specifies whether or not the new scope is an isolate scope. Isolate scopes do not inherit properties from their parent scope.

Isolate scopes are most often encountered when creating a directive and specifying scope: {...} in the options object. See Isolating the Scope of a Directive for more on that.

like image 158
Chris Bouchard Avatar answered Sep 28 '22 06:09

Chris Bouchard