Angular js interview question answer for fresher

Page 6

Q4. Explain all the below given key features of AngularJS. a. Scope: Scope is a JavaScript object that refers to the application model. It acts as a context for evaluating angular expressions. Basically, it acts as glue between controller and view. Scopes are hierarchical in nature and follow the DOM structure of your AngularJS app. AngularJS has two scope objects: $rootScope and $scope.

b. Controller: AngularJS application mainly relies on controllers to control the flow of data in the application. A controller is defined using ng-controller directive. A controller is a JavaScript object containing attributes/properties and functions. Each controller accepts $scope as a parameter which refers to the application/module that controller is to control.

c. Model: Models are plain old JavaScript objects that represent data used by your app. Models are also used to represent your app's current state.

d. View: The view is responsible for presenting your models data to end user. Typically it is the HTML markup which exists after AngularJS has parsed and compiled the HTML to include rendered markup and bindings. e.

Services: Services are singletons, which are objects that are instantiated only once per app (by the $injector). They provide an interface to keep together methods that relate to a specific function. AngularJS provides many inbuilt services for example, $http, $route, $window, $location etc. Each service is responsible for a specific task for example, $http is used to make ajax call to get the server data. $route is used to define the routing information and so on. Inbuilt services are always prefixed with $ symbol.

f.

Data-binding: AngularJS data-binding is the most useful feature which saves you from writing boilerplate code (i.e. the sections of code which is included in many places with little or no alteration). Now, developers are not responsible for manually manipulating the DOM elements and attributes to reflect model changes. AngularJS provides two-way databinding to handle the synchronization of data between model and view.

g. Directives: Directives might just be the killer feature of AngularJS. Directives allow us to extend the grammar of the web through reusable HTML elements, attributes, and classes. AngularJS directives are extended HTML attributes with the prefix ng-.

h. Filters: Filters are used to change modify the data and can be clubbed in expression or directives using pipe character. AngularJS filters can be used to transform data: 1.currency Format a number to a currency format. 2. filter - Select a subset of items from an array. 3. lowercase - Format a string to lower case. 4. orderBy - Orders an array by an expression. 5. uppercase - Format a string to upper case.

Q5. What is ng-app, ng-init and ng-model? Please explain in brief. ADMEC MULTIMEDIA INSTITUTE nd

C-7/114, 2 Floor, Sector- 7, Rohini, Delhi- 85, Landmark: Near Rohini East Metro Station www.admecindia.co.in, +91 9811 818 122, +91 9911 782 350, info@admecindia.co.in


Issuu converts static files into: digital portfolios, online yearbooks, online catalogs, digital photo albums and more. Sign up and create your flipbook.