Q1 : What are services in AngularJS ?
A : In AngularJS services are the singleton objects or functions that are used for carrying out specific tasks. It holds some business logic and these function can be called as controllers, directive, filters and so on.
Q2 : What are the advantages of using AngularJS ?
A : AngularJS has several advantages in web development.
- AngularJS supports MVC pattern
- Can do two ways data binding using AngularJS
- It has per-defined form validations
- It supports both client server communication
- It supports animations
Q3 : What is data binding in AngularJS ?
A : Automatic synchronization of data between the model and view components is referred as data binding in AngularJS. There are two ways for data binding
- Data mining in classical template systems
- Data binding in angular templates
Q4 : What is factory method in AngularJS?
A : 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.
Q5 : What are the characteristics of “Scope”?
A :
- To observer model mutations scopes provide APIs ($watch)
- To propagate any model changes through the system into the view from outside of the Angular realm
- A scope inherits properties from its parent scope, while providing access to shared model properties, scopes can be nested to isolate application components
- Scope provides context against which expressions are evaluated
Q6 : What are the advantages of using Angular.js framework ?
A : Advantages of using Angular.js as framework are
- Supports two way data-binding
- Supports MVC pattern
- Support static template and angular template
- Can add custom directive
- Supports REST full services
- Supports form validations
- Support both client and server communication
- Support dependency injection
- Applying Animations
- Event Handlers
Q7 : Who created Angular JS ?
A : Intially it was developed by Misko Hevery and Adam Abrons. Currently it is being developed by Google.
Q8 : What is the difference between AngularJS and backbone.js?
A : 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.
Q9 : Explain what is DI (Dependency Injection ) and how an object or function can get a hold of its dependencies ?
A : DI or Dependency Injection is a software design pattern that deals with how code gets hold of its dependencies. In order to retrieve elements of the application which is required to be configured when module gets loaded , the operation “config” uses dependency injection.
These are the ways that object uses to hold of its dependencies
- Typically using the new operator, dependency can be created
- By referring to a global variable, dependency can be looked up
- Dependency can be passed into where it is required
Q10 : What is injector?
A : An injector is a service locator. It is used to retrieve object instances as defined by provider, instantiate types, invoke methods and load modules. There is a single injector per Angular application, it helps to look up an object instance by its name.
Q11 : Explain what is linking function and type of linking function?
A : Link combines the directives with a scope and produce a live view. For registering DOM listeners as well as updating the DOM, link function is responsible. After the template is cloned it is executed.
- Pre-linking function: Pre-linking function is executed before the child elements are linked. It is not considered as the safe way for DOM transformation.
- Post linking function: Post linking function is executed after the child elements are linked. It is safe to do DOM transformation by post-linking function
Q12 : What is string interpolation in Angular.js ?
A : In Angular.js the compiler during the compilation process matches text and attributes using interpolate service to see if they contains embedded expressions. As part of normal digest cycle these expressions are updated and registered as watches.
Q13 : What makes AngularJS better ?
A :
- Registering Callbacks: There is no need to register callbacks . This makes your code simple and easy to debug.
- Control HTML DOM programmatically: All the application that are created using Angular never have to manipulate the DOM although it can be done if it is required
- Transfer data to and from the UI: AngularJS helps to eliminate almost all of the boiler plate like validating the form, displaying validation errors, returning to an internal model and so on which occurs due to flow of marshalling data
- No initilization code: With AngularJS you can bootstrap your app easily using services, which auto-injected into your application in Guice like dependency injection style
Q14 : With options on page load how you can initialize a select box ?
A : You can initialize a select box with options on page load by using ng-init directive
- <div ng-controller = ” apps/dashboard/account ” ng-switch
- On = “! ! accounts” ng-init = ” loadData ( ) “>
Q15 : What is scope in AngularJS ?
A : Scope refers to the application model, it acts like glue between application controller and the view. Scopes are arranged in hierarchical structure and impersonate the DOM ( Document Object Model) structure of the application. It can watch expressions and propagate events.
Q16 : What is AngularJS?
A : AngularJS is a javascript framework used for creating single web page applications. It allows you to use HTML as your template language and enables you to extend HTML’s syntax to express your application’s components clearly.
Q17 : What are the key features of AngularJS ?
A : The key features of AngularJS are
- Scope
- Controller
- Model
- View
- Services
- Data Binding
- Directives
- Filters
- Testable
Q18: What is Angular Expression? Explain what is key difference between angular expressions and JavaScript expressions?
A : Like JavaScript, Angular expressions are code snippets that are usually placed in binding such as {{ expression }}
The key difference between the JavaScript expressions and Angular expressions
- Context : In Angular, the expressions are evaluated against a scope object, while the Javascript expressions are evaluated against the global window
- Forgiving: In Angular expression evaluation is forgiving to null and undefined, while in Javascript undefined properties generates TypeError or ReferenceError
- No Control Flow Statements: Loops, conditionals or exceptions cannot be used in an angular expression
- Filters: To format data before displaying it you can use filters
Q19 : What are directives ? Mention some of the most commonly used directives in AngularJS application ?
A : A directive is something that introduces new syntax, they are like markers on DOM element which attaches a special behavior to it. In any AngularJS application, directives are the most important components.
Some of the commonly used directives are ng-model, ng-App, ng-bind, ng-repeat , ng-show etc.
Q20 : What Angular JS routes does ?
A : Angular js routes enable you to create different URLs for different content in your application. Different URLs for different content enables user to bookmark URLs to specific content. Each such bookmarkable URL in AngularJS is called a route.
A value in Angular JS is a simple object. It can be a number, string or JavaScript object. Values are typically used as configuration injected into factories, services or controllers. A value should be belong to an AngularJS module.
Injecting a value into an AngularJS controller function is done by adding a parameter with the same name as the value.
Q21 : Explain the concept of scope hierarchy.
A : Each AngularJS application has only one root scope. Child controllers, however, create a scope for each view. When the new scopes are created, they are added to their parent root scope as child scopes. This creates a hierarchical structure when they are attached.
Q22 : In what ways can you use a directive?
A : You can use a directive as an element, attribute or class name. To define the way your directive will be used, you need to set the restrict option in the directive declaration. The restrict option can be set to:
‘A’ – Only matches attribute name
‘C’ – Only matches class name
‘E’ – Only matches element name
You can combine these restrictions to produce needed results.
Q23 : Explain e2e testing of AngularJS applications.
A : End-to-end (e2e) testing involves testing an application from start to finish to determine whether all the components are working properly. It catches issues within an application related to integration and flow.
Q24 : What are the benefits of dependency injection?
A : Dependency injection has two major benefits: Testing and decoupling.
Q25 : What is Single Page Application (SPA)?
A : SPA is the concept whereby pages are loaded from the server not by doing post backs, rather by creating a single shell page or master page and loading the web pages into the master page.