Chapter 2: Basic AngularJS Directives Flashcards

1
Q

What are modules?

A

Resubale packages of code

Modules have their own services, controllers, directives and factories.

Can be linked to other modules to complete tasks.

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

How do you define a module?

A

angular.module(‘notesapp’, []);

in the ( ) we have the module name in ‘’ and then an array that we can list any dependent modules

The module definition would be script tags as well

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

What are controllers?

A

The javascript functions that perform majority of work with the UI

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

How do I set up a controller

A

On an element we use the ng-controller directive and give it a name

Then in our script we use the controller function. We pass it two arguments, name of the controller and then the code to execute.

angular.module(‘notesApp’, [])
.controller(‘MainCtrl’, [function() {
// Controller-specific code goes here
console.log(‘MainCtrl has been created’);
}]);

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

What is controllerAs syntax?

A

It allows us to specify a nickname for the controller

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

If we use the this keyword when defining variables in a controller what does it allow us to do?

A

Write that variable to the page

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