AngularJS Code Understanding -
can please me explain code segment in angularjs
$rootscope.compiledscope = $scope.$new(!0, $rootscope), $scope.variable = "somevalue"; - what $new operator serving here
- what !0?
- how , used separate 2 statements , assign 1 variable on left
from documentation, $new function accepts 2 parameters.
first part:
$new(isolate, parent); isolate : if true creates isolate scope new scope creating. means wont inherit parent scope. inherit parent scope parent scope properties wont visible it.
parent :
$scopeparent of newly created scope.!0 : in programming languages 0 == false. , negating give
true.
so deciphering first part of code:
$rootscope.compiledscope = $scope.$new(!0, $rootscope) add property called compiledscope $rootscope value new isolate scope parent $rootscope.
isolate scope : scope not prototypically inherit parent scope. empty scope , non of parent's properties visible it.
second part
$scope.variable = "somevalue"; attach variable $scope , sets value somevalue. , comma in between separates 2 statement , same doing:
$rootscope.compiledscope = $scope.$new(!0, $rootscope); $scope.variable = "somevalue";
Comments
Post a Comment