AngularJS Getting Started Tutorial (Zero): Bootstrap_AngularJS
We are now ready to write the AngularJS application - phonecat. In this step (Step 0), you will become familiar with the important source code files, learn to start the development environment containing the AngularJS seed project, and run the application in the browser.
Enter the angular-phonecat directory and run the following command:
git checkout -f step-0
This command will reset the working directory of the phonecat project. It is recommended that you run this command at each learning step and change the number in the command to the number corresponding to your learning step. This command will clear the changes you made in the working directory. any changes.
Run the following command:
node scripts/web-server.js
to start the server. After starting, the command line terminal will prompt Http Server running at http://localhost:8000. Please do not close the terminal. Closing the terminal will shut down the server. Enter http://localhost:8000/app/index.html in the browser to access our phonecat application.
Now, you should have seen our initial application in the browser, it is very simple, but it shows that our project is ready to run.
The "Nothing here yet!" displayed in the application is constructed from the following HTML code. The code contains the key elements of AngularJS, which is what we need to learn.
app/index.html
Nothing here {{'yet' '!'}}
What is the code doing?
ng-app directive:
ng-app directive marks the scope of the AngularJS script. Adding the ng-app attribute to means that the entire is the scope of the AngularJS script. Developers can also use the ng-app directive locally, such as
AngularJS script tag:
This line of code loads the angular.js script. When the browser completes loading the entire HTML page, it will execute the angular.js script. After the angular.js script is run, it will look for the HTML tag containing the ng-app directive. , this tag defines the scope of the AngularJS application.
Expression bound by double braces:
Nothing here {{'yet' '!'}}
This line of code demonstrates the core function of AngularJS templates - binding. This binding consists of double curly brackets {{}} and the expression 'yet' '!'.
This binding tells AngularJS that it needs to evaluate the expression and insert the result into the DOM. In the next steps, we will see that the DOM can be updated in real time as the expression operation result changes.
AngularJS expression Angular expression is a code snippet similar to JavaScript. AngularJS expression only runs in the scope of AngularJS instead of running in the entire DOM.
Bootstrap AngularJS application
Automatically booting AngularJS applications through the ngApp directive is a concise way and suitable for most situations. In advanced development, such as using scripts to load applications, you can also use bootstrap to manually bootstrap AngularJS applications.
There are three important points in the AngularJS application bootstrapping process:
1. The injector will be used to create dependency injection for this application;
2. The injector will create the root scope as the scope of our application model;
3. AngularJS will link to the DOM in the root scope, starting from the HTML tag marked with ngApp, and gradually process the instructions and bindings in the DOM.
Once the AngularJS application is booted, it will continue to listen to the browser's HTML-triggered events, such as mouse click events, key events, HTTP incoming responses and other events that change the DOM model. Once such an event occurs, AngularJS will automatically detect the change and handle and update it accordingly.
The structure of the above application is very simple. The template package contains only one directive and one static binding, and the model is also empty. Next we try a slightly more complex application!
What are these files in my working directory for?
The above application comes from AngularJS seed project, we can usually use AngularJS seed project to create new projects. The seed project includes the latest AngularJS code base, test libraries, scripts and a simple application example, which contains the basic configuration required to develop a typical web application.
For this tutorial we made the following changes to the AngularJS seed project:
1. Delete the sample application;
2. Add mobile phone images to app/img/phones/;
3. Add mobile phone data file (JSON) to app/phones/;
4. Add Twitter Bootstrap files to app/css/ and app/img/.
Practice
Try adding new expressions about mathematical operations to index.html:
1 2 = {{ 1 2 }}
Summary
Now let’s move to step 1 and add some content to the web application.

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

With the continuous development of Internet technology, Web development technology is also constantly updated and iterated. As an open source programming language, PHP is widely used in web development. As one of the commonly used tools in PHP development, the PHP framework can improve development efficiency and code quality. This article will introduce you to a PHP framework - CakePHP, and provide some simple tutorials to get started. 1. What is CakePHP? CakePHP is a model based on MVC (Model-View-Control

Install Windows 11 on Microsoft Surface Duo Remember, the steps described below apply to unlocked and AT&T models of Surface Duo. Surface Duo2 powered by Qualcomm Snapdragon 888 processor is completely incompatible with this module. Warning: Before we learn how to dual-boot Windows 11 on Microsoft Surface Duo, remember to take an off-device backup. This is because the process requires erasing all data on the phone, including files in the internal storage. You might brick your device permanently, so only try this if you know what you're doing

How to Use macOS Recovery to Install macOS on a New SSD On any Mac built after 2009, there is a built-in recovery system. This allows you to boot your Mac into recovery mode. In this mode, you can repair the internal disk, restore files from a Time Machine backup, get online help, or reinstall macOS. You must have an Internet connection to use these tools. You can use the macOS installation tool to install macOS on a new SSD installed in your computer. To use Internet Recovery to install macOS on an SSD: Follow the manufacturer's instructions

Concise and easy-to-understand MyBatis introductory tutorial: write your first program step by step MyBatis is a popular Java persistence layer framework that simplifies the process of interacting with databases. This tutorial will show you how to use MyBatis to create and perform simple database operations. Step 1: Environment setup First, make sure your Java development environment has been installed. Then, download the latest version of MyBatis and add it to your Java project. You can download it from the official website of MyBatis

Lumen is a PHP-based microframework developed by Laravel framework developers. It was originally designed to quickly build small API applications and microservices, while retaining some components and features of the Laravel framework. The Lumen framework is lightweight, fast, and easy to use, so it has received widespread attention and use. In this article, we will quickly get started with the Lumen framework and learn how to use the Lumen framework to build simple API applications. Framework preparation Before learning the Lumen framework, we need to

Javascript is a very unique language. It is unique in terms of the organization of the code, the programming paradigm of the code, and the object-oriented theory. The issue of whether Javascript is an object-oriented language that has been debated for a long time has obviously been There is an answer. However, even though Javascript has been dominant for twenty years, if you want to understand popular frameworks such as jQuery, Angularjs, and even React, just watch the "Black Horse Cloud Classroom JavaScript Advanced Framework Design Video Tutorial".

In today's information age, websites have become an important tool for people to obtain information and communicate. A responsive website can adapt to various devices and provide users with a high-quality experience, which has become a hot spot in modern website development. This article will introduce how to use PHP and AngularJS to build a responsive website to provide a high-quality user experience. Introduction to PHP PHP is an open source server-side programming language ideal for web development. PHP has many advantages, such as easy to learn, cross-platform, rich tool library, development efficiency

With the continuous development of the Internet, Web applications have become an important part of enterprise information construction and a necessary means of modernization work. In order to make web applications easy to develop, maintain and expand, developers need to choose a technical framework and programming language that suits their development needs. PHP and AngularJS are two very popular web development technologies. They are server-side and client-side solutions respectively. Their combined use can greatly improve the development efficiency and user experience of web applications. Advantages of PHPPHP
