Angular.js Flashcards

(20 cards)

1
Q

What is ng-app?

A

ng-app is a directive that designates the root element of your application. There can only be one ng-app that’s auto-bootstrapped per application and it usually lives in body or html tags

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What is ng-Controller

A

This directive creates a new controller object and a new child scope which is made available as an injectable parameter to the controller function as a $scope. Controllers can be used to set up the initial state of $scope object and add behavior to said object

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What is data-binding?

A

Data-binding in angular apps is the automatic synchronization of data between the models and view components.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

What is the model in MVC?

A

Models hold information, but rarely handle behavior, They don’t format info or influence how data appears in browser.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

What is Model View ViewModel?

A

An architectural pattern based on MVC and MVP which separates user-interface from logic and behavior in an application.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

Can you use more than one controller on a page

A

Yes using ng-Controller to define the scope

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

What is two-way-data binding

A
  1. When properties in the model get updated so does the UI
  2. When UI elements get updated, the changes get propagated back to the model.
    - this is how the UI can stay separated from the logix
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

What is a scope object and properties?

A

Scope.person is an object of scope, and name is a property of scope. and can be written like this: $scope.person = {
name:”Kate”
};

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

What is scope?

A

Scope is the glue between the app controller and the view. Directives and controllers have references to the $scope but not each other. Basically a javascript object with properties and methods

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

ng-repeat directive

A
//App Js
app.controller('MainCtrl', function($scope) {
  $scope.persons = [
    'Jack',
    'Jill',
    'Tom',
    ];
});
//Index.html
<p>
  Hello {{person}}!
</p>
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

Angular uppercase filter

A

<div>
<p>The name is {{ lastName | uppercase }}</p>
</div>

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

ng-model directive

A

With the ng-model directive you can bind the value of an input field to a variable created in AngularJS. The binding goes both ways. If the user changes the value inside the input field, the AngularJS property will also change it’s value. The ng-model directive can provide status for application data (invalid, dirty, touched, error):

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

Why use angular services?

A
  1. Shares data between controllers
  2. Keeps business logic inside Controllers and data logic inside services.
  3. DRY
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

What is persistent data?

A

Persistent Data denotes information that is infrequently accessed and not likely to be modified.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

Factory

A

When you’re using a Factory you create an object, add properties to it, then return that same object. When you pass this service into your controller, those properties on the object will now be available in that controller through your factory.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

How do you inject a service into our controller so we can access its data

A
Add the name of the service as a parameter to the controller you wish to access it from:
app.controller('MainCtrl', [
'$scope',
'posts',
function($scope, posts){
  ...

)};

17
Q

How do you include a dependency in app?

A

angular.module(‘flapperNews’, [‘ui.router’])

18
Q

What is $stateProvider

A
  1. A state corresponds to a “place” in the application in terms of the overall UI and navigation.
  2. A state (via the controller / template / view properties) describes what the UI looks like and does at that place.
  3. States often have things in common, and the primary way of factoring out these commonalities in this model is via the state hierarchy, i.e. parent/child states aka nested states.
19
Q

What is $urlRouterProvider? How do you redirect to default view if other views arent found?

A

Changes/redirects to urls based on state.

$urlRouterProvider.otherwise(‘home’);

20
Q

What is the $stateParams service?

A

The $stateParams service is an object that can store information about a url.