50 likes | 71 Views
If you're looking for Angular JS Interview Questions for Experienced or Freshers, you are at right place. Mindmajix offers Advanced Angular JS Interview Questions 2018 that helps you in cracking your interview & acquire dream career as Angular JS Developer.
E N D
Top AngularJS Interview Questions • Q. Databinding in angularjsAngular remembers the value and compares it to previous value. This is basic dirty-checking. If there is a change in value, then it fires the change event. • The $apply() method, which is what you call when you are transitioning from non-angular world into angular world, calls $digest(). A digest is just plain old dirty-checking. It works on all browsers and is totally predictable. • To contrast dirty-checking (angular) vs change listeners (KO, backbone): While dirty-checking may seem simple, and even inefficient, (I will address that later), it turns out that it is semantically correct all the time, while change listeners have lots of weird corner cases and need things like dependency tracking to make it more semantically correct. KO dependency tracking is a clever feature for a problem which angular does not have.
Q. Cannot get to $rootScopeYou can not ask for instance during configuration phase – you can ask only for providers.Skip code blockvar app = angular.module(‘modx’, []);// configure stuffapp.config(function($routeProvider, $locationProvider) {// you can inject any provider here});// run blocksapp.run(function($rootScope) {// you can inject any instance here}); • Q. How to preventDefault on anchor tags?UPDATE: I’ve since changed my mind on this solution. After more development and time spent working on this, I believe a better solution to this problem is to do the following:Click HereAnd then update your css to have an extra rule:a{cursor: pointer;}Its much more simple and provides the exact same functionality and is much more efficient. Hope that might be helpful to anyone else looking up this solution in the future.
Q. Difference between service, directive and moduleThink of a module as being a place to wire up a number of other things, such as directives, services, constants etc. Modules can be injected into other modules giving you a high level of reuse.When writing an angular app, you would have a top-level module which is your application code (sans templates) • services are mainly a way to communicate between controllers, but you can inject one service into another. services are often used as a way to get to your data stores and people will wrap the angular api’s such as ngResource. This technique is useful since it makes testing (particularly mocking) quite easy. You can have services for doing other things like authentication, logging etc.directives are used for creating widgets or wrapping existing things like jqueryplugins. Wrapping existing plugins can be a challenge and the reason you would do this is to establish a two-way data binding between the plugins and angular. If you don’t need two-way data binding then you don’t need to wrap them. • directives are also a place to do DOM manipulation, catching DOM-events etc. You should not be doing DOM-related stuff in controllers or services. creating directives can get pretty complex, IMHO, I recommend first looking to api for something that will do what you are looking to do OR ask angular googlegroup for advice.
For More Interview Questions • If you're looking for Angular JS Interview Questions for Experienced or Freshers, you are at right place. • Mindmajix offers Advanced Angular JS Interview Questions 2018 that helps you in cracking your interview & acquire dream career as Angular JS Developer.