一、angularjs基礎瞭解

來源:互聯網
上載者:User

標籤:儲存   scope   log   架構   blog   tor   actor   儲存   for   

說明:此處比較雜,目前沒有統一的總結哦

  • angularjs 是mvvm架構
  • 載入JS檔案總是使用尾碼為.min.js的檔案,因為這些檔案是經過壓縮的,能提升應用的啟動速度

模組說明:

1、config只能注入 provide 和 constant 2、factory、service 一般用於定義公用函數,使用factory需要返回一個對象,service與controller相似常用於儲存臨時資料3、constant 只用於存放常量資訊,這裡避免使用全域變數,定義方法:angular.module(‘app‘).constant(myname,‘myname‘)4、factory、service、constant、value、provider可以被注入5、run.js檔案放啟動時需要需要預先處理的邏輯6、bootstrap 依賴於jquery,所以在使用bootstrap時必須引用jquery7、一般頁面的結構:
<!DOCTYPE html><html>    <head>        <meta charset="utf-8">        <title>Angularjs Form Example</title>        <link href="bower_components/bootstrap/dist/css/bootstrap.min.css" rel="stylesheet">    </head>    <body ng-app="app">        <article ng-controller=‘formCheckCtrl as formCheck‘>            <section class="container-fluid">            </section>        </article>        <script src="bower_components/angular/angular.min.js"></script>        <script src="src/config/app.js"></script>        <script src="src/config/config.js"></script>        <script src="src/config/run.js"></script>        <script src="src/filters/password.js"></script>        <script src="src/factory/platform.js"></script>        <script src="src/controllers/formCheckCtrl.js"></script>    </body></html>

8、angular.extend的用法:對象中有的則覆蓋或者更新對象中的值,如果對象中沒有資料則補上。

 

9、一般的登入資訊等使用者關鍵資訊,使用localStorage儲存,需要外掛程式ngStorage

 

10、使用監控:$scope.$watch(XXXX,XXXXX),

 

若使用vm的形式需要這樣寫:

 

$scope.$watch(function(){return vm.password;},checkpassword);

 

如果使用$scope的形式:

 

$scope.$watch("$scope.password",checkpassword);

 

一、angularjs基礎瞭解

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.