Asas untuk bermula dengan angularJS_AngularJS

WBOY
Lepaskan: 2016-05-16 16:15:07
asal
1203 orang telah melayarinya

bersudut   

Semua perpustakaan digunakan, semua CDN digunakan:

Salin kod Kod adalah seperti berikut:


.contoh pengikatan data sudut, ini adalah yang paling asas, semua cabang dan daun sudut bermula dari sini:.

Salin kod Kod adalah seperti berikut:

http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd" >
http://www.w3.org/1999/xhtml">


sudut
  
   


   


   
   

       

            通过angular,展示数组对应的数据;
       

       

           

               
                    .s{
                        warna:#f00;
                    }
                    li{
                        kursor: penunjuk;
                    }
               
               

                       

  •                         {{i.name}}----{{i.age}}
                       

  •                

               
                    //angular.module("arr-app", []);
                    fungsi arrCon($skop) {
                        $scope.flag = 0;
                        $scope.bered = fungsi(i) {
                            $scope.flag = i;
                        };
                        $scope.lists = [
                            {nama : "hehe",
                                umur:10},
                            {
                                nama : "xx",
                                umur : 20
                            },
                            {
                                nama : "yy",
Umur: 2
                                                                                                                                                                                                                                                                                                                                       Nama: "jj",
Umur: 220
                                                                                                                                                        ]
                    };
                                                                                                                                                                                                                                                                                                                                                                                                                            






.DEMO penapis data:


Salin kod

Kod adalah seperti berikut:

http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd" >
http://www.w3.org/1999/xhtml">


sudut
  
   


   


   
   

       

            angular中的factory就相当于一个公用的实例方法,可以理解为一个多个控制器都可以用的函数;
       

       

            {{json}}
            <script><br>                 app.factory("ff", function() {<br>                     return {<br>                         "noting" : "json"<br>                     };<br>                 });<br>                 app.controller("factory", function($scope, ff) {<br>                     $scope.json = ff;<br>                 });<br>             </script>
       

   

   

       

            angular的指令;
       

         

                                                                  adakah anda berpuas hati?
                                                                                                                                           app.directive("heh", function() {
                       kembali {
                          had: "AE",
Gantikan : benar,
transclude : benar,
templat : '
'
                    };
                 })
                                                                                                                                                                                                                                                       





Menggunakan arahan .ng-switch (ini sangat serupa dengan templat, ia adalah klik biasa kami untuk menyembunyikan dan menunjukkan pemalam Tab dahulu)::

Salin kod Kod adalah seperti berikut:

http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd
" >
http://www.w3.org/1999/xhtml">


sudut
  
   


   


   


   
   

       

            使用模板
       

       

                       
           
                           
           

           

               
           

       

         


   
   

       

            updateangular的通知数据更新三种方式$scope.$digest(),$scope.$apply(),以及通过$scope.$watch监听进行更新;
       

       

            {{hehe}}
           
           

                the value set by $scope.$watch ==>> {{wat}}
           

           

           
       

         


   
   

       

            angular中的工具方法列表
       

       

           
             
  • angular.bind

  •              
  • angular.bootstrap

  •              
  • angular.copy

  •              
  • angular.element

  •              
  • angular.equals

  •              
  • angular.extend

  •              
  • angular.forEach

  •              
  • angular.fromJson

  •              
  • angular.identity

  •              
  • angular.injector

  •              
  • angular.isArray

  •              
  • angular.isDate

  •              
  • angular.isDefined

  •              
  • angular.isElement

  •              
  • angular.isFunction

  •              
  • angular.isNumber

  •              
  • angular.isObject

  •              
  • angular.isString

  •              
  • angular.isUndefined

  •              
  • angular.huruf kecil

  •              
  • angular.module

  •              
  • angular.noop

  •              
  • angular.reloadWithDebugInfo

  •                                                                                                                                                                                                                                   … angular.toJson
                              
  • angular.uppercase

  •                                                                                                                                                                                      

    Alat dan kaedah ini serupa dengan perpustakaan lain;
                      angular.element ialah JQ kecil untuk anguarLite memilih elemen;
                                                                                                          Angular.module ialah kaedah elemen modul;
                                                                                                                                                                                                                                                                                                                                     






    Penggunaan ng-transclude (ini adalah kes rasmi), kodnya adalah seperti berikut:

    Salin kod

    Kod adalah seperti berikut:

    http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd
    ">
    http://www.w3.org/1999/xhtml">


    angular
      
       


       
       

           

                ng-transclude的使用(这个是官方的案例):
           

           

               

                 

                 

                  {{text}}
               

           

           

    Tutorial Popular
    Lagi>
    Muat turun terkini
    Lagi>
    kesan web
    Kod sumber laman web
    Bahan laman web
    Templat hujung hadapan