Instructions for installing AngularJS
This article will show you how to install the AngularJS library for use in web application development. We will introduce about the structure of the ink and its contents.
When you visit https://angularjs.org/, you will see there are 2 options to download AngularJS as GitHub and download directly to your computer.
- View on GitHub - Click this button to access GitHub, where you will have the latest AngularJS version.
- Download - Or click this button and the following screen will appear:
This screen has a lot of options, but for simplicity, you should only choose CDN.
After downloading CDN to your computer, you copy and paste it at any drive. I paste it at drive D with the path D: angular.min.js . Why pay attention to this, you follow the first example of the next AngularJS will be clear.
Now that you've installed AngularJS, it's really simple, isn't it?
The first example of AngularJS
Now, I started writing a simple example using the AngularJS library. First, I created the viduAngularJS.html page as below:
Chao mung ban den voi {{xinchao.tieude}} taiQTM.com!
Open an editor, notepad, copy the above code and save it with any name (viduAngularJS.html for example), but you must remember that its extension is .html. Next, I present the components in the AngularJS example above.
Cover the AngularJS library
To declare JavaScript in your code, you can declare the following:
This is the first way. This way has included the AngularJS library online (available online, because it is Google's free open library). If you do not want to use this method, you follow the following method.
Here, I cover the AngularJS library according to the path I just downloaded. Generally both ways are the same. You can try again. (Remember to have a .js tail.)
Point to AngularJS application
The next part is the HTML section containing the AngularJS application. This is added by the ng-app attribute at the root element of HTML in the AngularJS application. You can either add to the html element or in the body element as follows:
ng-app = "ungdungdautien" >
View components in AngularJS
View is the following component:
ng-controller = "ViduController" >
Chao mung ban den voi {{xinchao.tieude}} tai QTM.com!
ng-controller informs AngularJS which controller is used in the view. xinchao.tieude informs AngularJS to write the value of the model with the name xinchao.tieude in the HTML section.
Controller component in AngularJS
Controller is the following part:
The above code registers a controller function with the name ViduController in AngularJS module with the name ungdungdautien . We will learn more about the Modules and Controller Components in the corresponding chapters. The controller function is registered with AngularJS by calling angular.module (.) function. Controller (.).
The $ scope parameter passed to the controller function is a model . The controller function adds a JavaScript object, xinchao , and adds the tieude field to that object.
Execute AngularJS application first
After you save the code under the name viduAngularJS.html and open it under any web browser. You will see the results section as follows:
When the above page is loaded in that browser, the following will happen:
The HTML document will be loaded into the browser, estimated by the browser, AngularJS JavaScript loaded, the global objects of AngularJS are initialized. Then, JavaScript will register the controller function for execution.
Next AngularJS browses HTML elements to test AngularJS applications and views. When the view is found, it connects the view to the corresponding controller feature.
Next, AngularJS implements controller functions, and returns the result to the view with data that the model is initialized in the controller section. The website is completely uploaded.
According to Tutorialspoint
Previous lesson: Create a table in AngularJS
Next article: MVC structure in AngularJS
You should read it
May be interested
- Multilingual (i18n) in AngularJSangularjs provides multi-lingual functions (i18n) with 3 types of filters, currency, date and number. we just need to combine the js corresponding to the location depending on the country. by default it will attach to the location in the web browser.
- Expression in AngularJSexpression is used to bind application data to html tags. expression is written in {{expression}}. expression has a similar way of operating as the ng-bind directive.
- Controller component in AngularJSan angularjs application works primarily based on the controller component to control the flow of data in the application.
- MVC structure in AngularJSmodel view controller or mvc is a popular call, a software design model for web-based applications.
- Create the table in AngularJStable data is often repeated in natural order. in angularjs, ng-repeat directive can be used to draw tables easily. below is an example of how to use ng-repeat to create tables.
- Scope in AngularJSscope is a special javascript object with the role of linking controllers and views. scope contains information as model data. in the controller, model data can be accessed via the $ scope object.
- Instructions for checking and installing more RAM for laptops as quickly as possiblereplacing and installing more ram for your laptop is something that will have to be done if the ram is damaged or you want to upgrade. so what is the correct way to check and replace ram?
- Instructions for registering and installing Dropboxinstructions for registering and installing dropbox. dropbox is a cloud-based storage service with many good features and utilities that allows us to download and sync documents, photos, videos anytime, anywhere on different devices such as computers, electricity. phone.
- Instructions for installing Vietnamese for IDM for all versionsinstructions for installing vietnamese for idm for all versions. by default, idm's interface is in english, so it will be a bit difficult for newbies. however, we can completely install vietnamese language for idm if desired.
- Include syntax in AngularJShtml does not support embedding html web pages in html pages. to achieve this function, the following methods can be used: