python ruby-programming-language Smalltalk Vue.js Knockoutjs TypeScript JavaScript, OOPs JavaScript Angular 8,7,6,5,4 and 2 Interview Questions and Answers Angular 8,7,6,5,4 and 2 Interview Questions and Answers Angular 4 Angular 2 AngularJs 1.x NodeJs Perl Programming R Programming RequireJs Rust Programming Backbonejs closure programming language go-programming-language kotlin-programming-language
$new() or $rootScope.new() in angularjs

$new() or $rootScope.new() in angularjs

The Root Scope is creating by using the $rootScope.

Example code.

The below example going to show how to create the root scope using $rootScope.

var parentRoot = $rootScope;
parentRoot.Email = "[email protected]";//assign the email value.

//Used to check the parent email is equal to the given email.
//If return true then broadcast to "hi, your email is valid!! Thank you!!"
//If return true then broadcast to "hi, your email is not valid!! Please try again."
if (expect(parentRoot.Email).toEqual('[email protected]')) {
    parentRoot.$broadcast("Hi, your email is valid!! Thank you!!");
}
else {
    parentRoot.$broadcast("Hi, your email is not valid!! Please try again.");
}

The Child scopes are creating by using the $new() method.
The most of the scopes are created automatically at the time when compiled & executed to HTML page.

If you want to remove the scope from the hierarchy that time we using to $destroy() method.

Example code.

The below example going to show how to create the child root scope using $rootScope or parent scope.

var parentRoot = $rootScope;
var childRoot = parentRoot.$new();//Used the new method to get the child root.
childRoot.Email = "[email protected]"; //Assign to child root email.

//Used to check the child email is equal to the given emails.
//If return true then broadcast to "hi, your email is valid!! Thank you!!"
//If return true then broadcast to "hi, your email is not valid!! Please try again."
if (expect(childRoot.Email).toEqual('[email protected]')) {
    parentRoot.$broadcast("hi, your email is valid!! Thank you!!");
}
else {
    parentRoot.$broadcast("hi, your email is not valid!! Please try again.");
}


ANIL SINGH

Hi there! Welcome to my blog. My name is Anil Singh. I'm a author of this blog. For more detail about me, kindly refer to this link..
My Blogs - http://code-sample.com and http://code-sample.xyz
My Books - Interview Questions and Answers Books- Get Your Book in 15+ Digital Stores Worldwide..

You Might Also Like
www.code-sample.com/. Powered by Blogger.
ASK Questions