.Net Interview Questions and Answers

Search:

What is the need of $sce ? ( AngularJS Interview Questions)

By : Shiv Prasad Koirala | Jan 15th, 2016 | Views : 2034 | Comments : 0 Bookmark and Share

In case you are new to AngularJS I would recommend to start  Angular from basic.

 

"$sce" (Strict Contextual escaping) service helps to render trustful HTML from Angular. By default HTML is not rendered in angular. For example below is a simple angular controller with HTML content in one of its variable.

 

 
 

In order to render the above HTML content we have binded the same to the below "DIV" tag. To render HTML content we have used "ng-bind-html" attribute.

 

 

 

You would be surprised to know that the above code does not work. If you go to google chrome console (press f12) you would see that it has marked the HTML as unsafe. This is actually a great security feature. This ensures that any unsafe HTML and SCRIPTS are not rendered and executed with out checks.   

 

 

 

To mark the above HTML as safe we have used "trustAsHtml" from the "$sce" service.

 

 
 

With Angular server side MVC is also important , if you want to start with MVC start with the below MVC youtube video

 

 
Rate this Article :
1 Star
2 Stars
3 Stars
4 Stars
5 Stars
1 1 1 2 1
 
 
Comments

Write a Comment

All fields marked with * are mandatory

20f97

 

 
 

.NET interview questions 6th edition (Sixth edition) - By Shivprasad Koirala

In this article we will explain .NET interview questions 6th edition (Sixth edition) - By Shivprasad Koirala.... Read More

What is the difference between Stored Procedures and Function (SQL Server interview question with answers)?

In this article we will explain what is the difference between Stored Procedures and Function.For more articles and videos visit us on www.questpond.com... Read More

Explain MVC application life cycle?

In this article we will explain MVC application life cycle.For more articles and videos visit us on www.questpond.com... Read More

C# Design pattern interview questions with answers: - How Singleton is different from Static class?

In this article we will explain How Singleton is different from Static class.... Read More

WCF interview questions and answers: - What is the difference between Service endpoint and Client endpoint?

In this article we will explain What is the difference between Service endpoint and Client endpoint.... Read More

.NET interview questions 6th edition (Sixth edition) - By Shivprasad Koirala

In this article we will explain .NET interview questions 6th edition (Sixth edition) - By Shivprasad Koirala.... Read More

What is the difference between Stored Procedures and Function (SQL Server interview question with answers)?

In this article we will explain what is the difference between Stored Procedures and Function.For more articles and videos visit us on www.questpond.com... Read More

Explain MVC application life cycle?

In this article we will explain MVC application life cycle.For more articles and videos visit us on www.questpond.com... Read More

C# Design pattern interview questions with answers: - How Singleton is different from Static class?

In this article we will explain How Singleton is different from Static class.... Read More

WCF interview questions and answers: - What is the difference between Service endpoint and Client endpoint?

In this article we will explain What is the difference between Service endpoint and Client endpoint.... Read More

Article Categories

Learn in Hindi