Вы находитесь на странице: 1из 1

AngularJS

AngularJS is a JavaScript web framework aimed to make web apps simple to build and
easy to maintain.
We'll start by building a simple AngularJS app. After making this app, we'll generalize a
few steps that can be used to build more complex apps. By the end of this course, you'll
be able to use this sequence of steps to jumpstart your own AngularJS apps.
Awesome! You built an AngularJS app. How does it work?
1.
2.

3.

4.

5.

6.

In app.js, we created a new module namedMyApp. A module contains


the different components of an AngularJS app.
Then, in index.html we added<body ng-app="myApp">. The ng-app is
called a directive. It tells AngularJS that the MyAppmodule will live within
the <body> element, termed the application's scope. In other words, we
used the ng-app directive to define the application scope.
In MainController.js we created a
newcontroller named MainController. Acontroller manages the app's
data. Here we use the property title to store a string, and attach it
to $scope.
Then, in index.html, we added<div class="main" ngcontroller="MainController">. Like ng-app, ng-controller is
a directivethat defines the controller scope. This means that properties
attached to $scope inMainController become available to use
within <div class="main">.
Inside <div class="main"> we
accessed$scope.title using {{ title }}. This is called an expression.
Expressions are used to display values on the page.
The value of title showed up when we viewed the app in the browser.

Вам также может понравиться