AngularJS Code Understanding -


can please me explain code segment in angularjs

$rootscope.compiledscope = $scope.$new(!0, $rootscope), $scope.variable = "somevalue"; 
  1. what $new operator serving here
  2. what !0?
  3. 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 : $scope parent 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

Popular posts from this blog

php - Wordpress website dashboard page or post editor content is not showing but front end data is showing properly -

How to get the ip address of VM and use it to configure SSH connection dynamically in Ansible -

javascript - Get parameter of GET request -