Q & A - Angular Questions & Answers

 

Q&A 1.

Who created AngularJS?

AngularJS-large_cropped.png

AngularJS is a JavaScript framework. It was originally developed by Misko Hevery and Adam Abrons in 2009. Originally, it was GetAngular now it is maintained by Google. AngularJS is lightweight and easy to learn. It is perfect in developing Single Page Applications. AngularJS is open source, free of cost, and easy to handle. AngularJS is a efficient framework that can create Rich Internet Applications (RIA).

Q&A 2.

What is ng-show and ng-hide in angularjs?

We can use expressions to evaluate to boolean value to ng-show/ ng-hide directive binding, which helps display or hide html controls in a view.

Q&A 3.

Explain Angular $timeout wrapper.

Angular timeout helps performs timeout operation just like SetTimeout() in javascript. with $timeout and the model changes will be get reflected in the view automatically since angular invoke a digest cycle when the $timeout is done. AngularJS provides a wrapper $timeout which uses $apply internally to update any changes in UI.

Q&A 4.

How to bind html content in a view with AngularJS?

By using html attribute for angular ng-bind-html we can bind trusted html variable to a html tag in angularjs. like -
<h4 ng-bind-html="contentDescription"></h4>

Q&A 5.

What is the use of $sce.trustAsHtml() while binding html content in angular?

While binding any html content in angular as "contentDescription" above we need to first inject $sce in our controller, then instruct Angular to trust this content as HTML. Or Angular will generate an error -
"Attempting to use unsafe value in safe context on Angular".

var app = angular.module("MyApp", []);


 app.controller("homeCtrl", function ($scope, $sce) {
 $scope.content = "<b>An Overview of AngularJS.</b>";
 $scope.contentDescription = $sce.trustAsHtml(content);
 });

Related Quiz Content

x
This website is using cookies to make user experience of the site better. More info. OK