Preparing for an AngularJS Role
Here are some tips on killing your next Angular Interview. Be prepared to answer some basic questions on:
- dependency injection
- module definition and retrieval
- naming conventions
- file and folder structures for architecting large apps http://grumpywizards.com/ngtemplate/
You should know what happens when you minify and how to handle this.
Persisting Data in Angular
Sometimes you'll see data persisted in controllers. These get cleaned up everytime user switches a route. A better place is to keep this in services.
Create an object and return it. When passed into a controller, the properties defined on that object will be available in the controller.
Used like constructor functions. Any properties set on the this keyword will be available in the controller when this is passed in.
Can be passed into config(). When you need module-wide config for your service object.
Use protractor for E2E testing
Angular Style Guide
setTimeoutto make testing easier. Also do the same for
$interval, $window, $document, $http
- Use promises instead of callbacks
- Avoid globals and use dependency injection
- Avoid prefixing variables and methods with
- Karma is a command-line test runner. Protractor is for E2E tests in the browser.
- Event aggregation in Angular is done with $broadcast, $emit, and $on
- Exceptions are handled with the $exceptionHandler service. These can be decorated to log exceptions to a service.
- Interceptors are generally used to check authenticity of a request before sending to the server.
- Transforms allow us to tweak a response before or after an http request or response