prep for interview Flashcards
root scope
every ang js app has a root scope
all the child scopes inherit fom the root scope
Each view has its own $scope (which is a child of the root scope), so whatever variables one view controller sets on its $scope variable, those variables are invisible to other controllers.
$inject
can be used to inject dependencies
module config block vs module run block

ngChange
do something when an input value changes
nghref
used for adding links
inline templates vs external templates vs internal templates

services vs factories vs providers
both of them are used to share data across controllers
the syntax is however different for both
Substitutable objects that can be wired together using DI.
· Use services to share code and data across the app.
· Angular Services are lazily initialized (initiates only when its needed)
· Angular Services are singletons per Angular module.
· Angular has many in-built services (starting with $) e.g. $rootScope, $http, $routeProviders etc.

$window
Reference to native window object.
$window.alert(“vhjbvkh”);
$location

$document
jQuery/jqLite wrapper for window.document
$document[0].title

$timeout

$interval

$templateCache

$http.post vs jquery.post

what is routing?

$routeProvider and ngRoute
it can be injected as a parameter, while implementing routing in our application;
ngRoute module is or can be injected into our app
promise
http service - we make async rqst to server; using ‘get’ method for example - we can get or fetch json data from the server; this request returns a promise object with .success() and .error(); if we tell $http to fetch json , the result will be automatically be decoded into JS objects and arrays; $http returns a promise, so success() gets the data …
links
or example we are creating a note-taking app; if we hover over a note - we want to display the description; so we need jquery; so how do we do this? We use links to attach or put th jquery code into the directive; This is the best spot to do any DOM manipulation or logic functionality for your directive; the three automatically injected parameters are scope, element (refers to outermost element of the included template) and attribute (refers to the attributes on the directive element);
isolate scope
By passing an object to the scope option, you are creating an isolate scope. This tells the directive to keep scope inside of itself and not to inherit or share with other scopes.
$scope vs isolate scope
$scope - Allows you to set values as properties on our scope object.
scope: { } - Allows you to create an isolate scope private to this directive.
scope bindings
- Text Binding (Prefix: @) | Parsed as string and one-way binding
- One-way Binding (Prefix: &) | defined as getter functions and read-only inside directive’s scope
- Two-way Binding (Prefix: =) | Can be changed inside directive and reflects outside as well