Home > Web Front-end > JS Tutorial > angularjs basic tutorial_AngularJS

angularjs basic tutorial_AngularJS

WBOY
Release: 2016-05-16 16:24:34
Original
1217 people have browsed it

I haven’t written anything for a long time. I feel like I don’t even know where to start. Let’s write something technical first, angularjs – my brother calls it “忺哥拉js”

1. Download

Copy code The code is as follows:

Official website: <a href="https://angularjs.org/">https://angularjs.org/<code>官方网址:<a href="https://angularjs.org/">https://angularjs.org/</a>
CDN: <a href="https://ajax.googleapis.com/ajax/libs/angularjs/1.3.0-beta.5/angular.min.js">https://ajax.googleapis.com /ajax/libs/angularjs/1.3.0-beta.5/angular.min.js<code>CDN:<a href="https://ajax.googleapis.com/ajax/libs/angularjs/1.3.0-beta.5/angular.min.js">https://ajax.googleapis.com/ajax/libs/angularjs/1.3.0-beta.5/angular.min.js</a>

2. Brief introduction to use 1.ng-app

determines the scope of angularjs, you can use it as follows

Copy code The code is as follows:


… 

to let angularjs render the entire page, you can also use

Copy code The code is as follows:
<code><br> <font face="Arial"><div ng-app='myapp'><br> ……<br> </div></font><br>

to render part of it.

2.ng-model

ng-model, when your data model is changed, for example, ng-model='test', when the value of test is changed, the value of {{test}} will also change accordingly, that is The test connected to ng-model has also changed, as follows Copy code

The code is as follows:





          
& Lt; title & gt; learing argularjs-widuu & lt;/title & gt;


{{test}}

3.angular.module

This is mainly used for module registration, creation and indexing. For example, if our ng-app wants to register this as a service, we must use it. We also need to use it when we reference and index a module. Copy code

The code is as follows:


angular.module(name, [requires], [configFn]);
#name The name of the retrieval module created by type string
#requires A simple understanding is that you need to include the usage module, such as ngRoute routing module #configFn Optional function module, the function is similar to module.config

4.controller

Controller is the method controller(name, constructor) in angular.Module; where name is the name of the controller and constructor is the controller constructor. We use a piece of code to illustrate Copy code
The code is as follows:




          
         
         
       
        learing argularjs--widuu
   
   
    {{test}}
   


        {{output}}
   

6.provider

provider也是angular.Module中的方法provider(name, providerType);其中name是service的名称,providerFunction是函数用于创建新的服务器对象,这个跟factory差不多,我们现在用provider重写

复制代码 代码如下:



   
       
       
        learing argularjs--widuu
   
   
    {{test}}
   


        {{output}}
   

7.service

service也是angular.Module中的方法service(name, constructor);其中name是service的名称,constructor一个将被实例化的构造函数,这个跟factory差不多,我们现在用service重写

复制代码 代码如下:



   
       
       
        learing argularjs--widuu
   
   
    {{test}}
   


        {{output}}
   

8.constant

constant也是angular.Module中的方法constant(name, object);其中name是常量的名称,而object是常量的值,我们可以这样写的

复制代码 代码如下:



   
       
       
        learing argularjs--widuu
   
   
    {{test}}
   


        {{output}}
   

今天就写到这里,然后以后继续.

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template