






Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!







Ans: AngularJS is a JavaScript framework that is used for making rich and extensible web applications. It runs on plain JavaScript and HTML, hence you don’t need any other dependencies to make it work. AngularJS is perfect for Single Page Applications (SPA). It is basically used for binding JavaScript objects with HTML UI elements.
Ans: Its features include:
The Template (View) The Scope (Model) The Controller (Controller) Services Filters Directives
Ans: Data binding is an automatic attunement of data between the view and model components.
Ans: There are several differences between AngularJs and JavaScript expressions: We can write AngularJs expressions in HTML, but we cannot write JavaScript expressions in HTML. We cannot use conditional iterations, loops, and exceptions in AngularJs, but we can use all of these conditional properties in JavaScript expressions. Filters are supported in AngularJs whereas filters are not supported in JavaScript.
Ans: To set up an Angular App we must follow certain steps as mentioned below: angular.module will be created at first. A controller will be assigned to the module. The module will be linked with the HTML template(i.e. UI or View) with an angular app(ng-app). The HTML template will be linked with the controller(i.e. JS) with an ng-controller directive.
Ans: The angular modules collectively define an angular application where we can write the angular code. Modules contain the different parts of an angular application. A module is created by angular.module function in angular.
Ans: Three directive scopes are available in AngularJs. They are: Parent scope – Whatever change you make in your directive that comes from the parent scope, will also reflect in the parent scope, and it is also a default scope.
Ans: It is the $routeProvider that helps in navigating between different pages/links without separately loading the page/link whenever a user clicks on a link. ngRoute config() method is used to configure the routeProvider.
Ans: In AngularJs $scope is used to achieve dependency injection and scope is used for linking between View (i.e. HTML) and Controller (i.e. JS).
Ans: $$ variable in AngularJS is used as a private variable, as it is used to prevent accidental code collision with the user code. Whereas $ prefix can be used to denote angular core functionalities (like a variable, parameter, property or method).
Ans: Manipulation of DOM is in directives and apart from this it should not exist in controllers’ services or anywhere else.
Ans: To show one-time binding we have to use “ :: ” in front of the scope.
Ans: It is a web application which loads a single HTML page and dynamically updates the page as the user connects with the app. By using AJAX and HTML a fluid and responsive web app can be created by SPA without invariant page reloads. Through this, we can make responsive UI with no page flicker.
Ans: The binding directives include: ng-bind ng-bind-html ng-bind-template ng-non-bindable ng-model
Ans: ng-bind : It is a directive which replaces the content of the HTML element with the value of the assigned variable or expression. The content of the HTML element will change by changing the value of the variable or expression. It is like ({{expression}}) and the syntax for this is,
ng-bind-html : It is a directive which binds the content to the HTML element(view) in a secure way. $sanitize service is used to sanitize the content to bind into an HTML element. To do this ‘angular-sanitize.js’ must be included in our application. Syntax to write this,
Ans: ng-include helps to include different files on the main page. The ng-include directive includes HTML from an external file. The included content will be included as child nodes of the specified element. The value of the ng-include attribute can also be an expression, returning a filename. By default, the included file must be located on the same domain as the document.
ng-click can be used in scenarios like when you click on a button or when you want to do any operation. It tells AngularJS what to do when an HTML element is clicked. Example: OK The above code will increase the count variable by one whenever the button is clicked.
Ans: REST is an API style that operates over the HTTP request. The requested URL identifies the data to be operated on, and the HTTP method identifies the operation that is to be performed. REST is a style of API rather than a formal specification, and there is a lot of debate and disagreement about what is and isn’t RESTful, which is a term used to indicate an API that follows the REST style. AngularJS is flexible about how RESTful web services are consumed.
2. Template URL: This attribute specifies the AngularJs HTML compiler to replace the custom directive inside a template with the HTML content located inside a separate file. 3. Replace: It replaces the current element if the condition is true, if false append this directive to the current element. 4. Transclude: It allows you to move the original children of a directive to a location inside the new template. 5. Scope: It creates a new scope for this directive rather than inheriting the parent scope. 6. Controller: It creates a controller which publishes an API for communicating across the directives. 7. Require: It requires another directive to be present to function the current directive efficiently. 8. Link: It modifies the resulting DOM element instances, adds event listeners, and set up data binding. 9. Compile: It modifies the DOM template for features across copies of a directive, as when used in other directives. Your compile function can also return link functions to modify the resulting element instances.
Ans: Yes, it is possible as Nested Controllers are well-defined in a classified manner while using a view.
Ans: Yes, it is companionable with all browsers like Safari, Chrome, Mozilla, Opera, IE etc. as well as Mobile browsers.
Ans: AngularJS services are the singleton objects or functions which are used for carrying out definite tasks. It embraces some corporate ideas and these purposes can be called as controllers, directive, filters and so on.
Ans: Advantages of AngularJS include: AngularJS supports the MVC form. Organize two ways data binding using AngularJS. It supports mutual client-server communication. It supports simulations.
Ans: Factories are functions that return the object, while services are constructor functions of the object which is used by a new keyword. Syntax:
Factory – module.factory(factoryName, function); Service – module.service(serviceName, function);
Ans: Factory provider is preferred using an object, whereas a service provider is preferred using with class.
Ans: AngularJS is a TypeScript language-based JS framework released in October 2010 by Google. It is a completely free framework and open source that is used in SPA projects (i.e. Single Page Application projects). React.JS is a javascript library developed by Facebook in March 2013 for building UI. React components can be used on several pages but not as a SPA (i.e. Single Page Application).
Ans: ng-bind directive has one way data bindings, data flows only from object to UI, not vice versa (i.e. $scope>>view) and ng-model directive has two way data bindings, data flows between UI to object and vice versa(i.e. $scope>>view and view>>$scope).
Ans: AJAX stands for Asynchronous JavaScript which is used for sending and getting responses from the server without loading the page. Whereas, AngularJS is a typescript language-based JavaScript framework following the MVC pattern.
Ans: The main work of filters is to modify the data, so that it can be merged into an expression or directive by using a pipe character (it is used for applying filters in an angular symbol of a pipe which is (|) or this is the symbol). A filter formats the value of an expression for display to the user. They can be used in view templates, controllers, or services, and we can easily create our own filter as well. A filter is a module provided by AngularJS. There are nine components of a filter which are provided by AngularJS. Examples: currency, date, filter, json, limitTo etc.
Ans: It is used to define the AngularJs Application. It appoints the root element of an AngularJs application and it is kept near the or tag.
Syntax : module.factory(‘factoryName', function);
Ans: It renders or iterates over a collection of items and creates DOM elements. It regularly monitors the source of data to re-render a template in response to a change. Syntax:
{{stu.name}} {{stu. grade}}
Ans: ng-if directive is used as if clause which removes the HTML element if the expression becomes false. Syntax
ng-show directive is used to show the HTML element if the expression becomes true. And if the expression becomes false then the HTML element will be hidden. Syntax
ng-hide directive is used to hide the HTML element if the expression becomes false. Syntax
Both ng-show and ng-hide uses the display property method.
Ans: ngRoute is a module developed by angularJS team which was a part of the core angularJS framework. Whereas ui-router was developed by a third-party community to overcome the problems of ngRoute. ngRoute is a location or URL based routing, and ui-router is a state-based routing which allows nested views.
Ans: AngularJS has a module called ngCookies, so before injecting ngCookies angular- cookies.js should be included into the application. Set Cookies – Put method is used to set cookies in a key-value format. $cookies.put(“username”, $scope.username);
Get Cookies – Get method is used to get cookies. $cookies.get(‘username’); Clear Cookies – Remove method is used to remove cookies. $cookies.remove(‘username’);
AngularJS combines the functionalities of most of the 3rd party libraries, it supports individual functionalities required to develop HTML5 Apps. While Backbone.js do their jobs individually.
Ans: Intially it was developed by Misko Hevery and Adam Abrons. Currently it is being developed by Google.
Ans: For creating the directive, factory method is used. It is invoked only once, when compiler matches the directive for the first time. By using $injector.invoke the factory method is invoked.
Ans: In Angular.js the compiler during the compilation process matches text and attributes using interpolate service to see if they contain embedded expressions. As part of normal digest cycle these expressions are updated and registered as watches.
Ans: Automatic synchronization of data between the model and view components is referred as data binding in AngularJS. There are two ways for data binding
**10. Data mining in classical template systems
Ans: In AngularJS services are the singleton objects or functions that are used for carrying out specific tasks. It holds some business logic and these functions can be called as controllers, directive, filters and so on.