初學angular

angular是MVC的一個框架。

angular模塊化

1.定義模塊

angular.module('名字',[依賴的其他模塊]);

2.引用模塊

ng-app="模塊名字"

依賴項

$scope ? ? ? ? ? ng作用域,所有的ng數(shù)據(jù)都在$scope上 依賴項

$http

? ? ? ? ? ? ?$http.get();

? ? ? ? ? ? ?$http.get().then(function(){},function(){})

? ? ? ? ? ? ?$http.post();

? ? ? ? ? ? ? $http.jsonp();

$interval

$timeout

ng-指令

ng-app ? ? ? ? ??這個放哪就說明哪歸angular管 必須有

ng-controller

? ? ? ? ? ? ? ? 使用controller:

? ? ? ? ? ? ? ? 1.定義controller

? ? ? ? ? ? ? ? ?①angular.module('main',[]).controller('',function(){})

? ? ? ? ? ? ? ? ?②var app=angular.module('app',[]);? app.controller()

? ? ? ? ? ? ? ? ? 2.引用controller

?ng-controller="名字"

ng-init

ng-model

自定義controller:

模塊.controller(名字, function (){...controller代碼...});

自定義filter:

模塊.filter(名字, function (){...filter代碼...});

自定義directive:

模塊.directive(名字, function (){...directive代碼...});

自定義service:

模塊.service(名字, function (){...service代碼...});

自定義filter:

模塊.filter(名字, function (){

? ? ? ? ?return function (input, arg){

? ? ? ? ? ? ? ? ? return '處理好的結(jié)果';

? ? ? ? ? ?};

});

使用:

{{數(shù)據(jù)|filter:"參數(shù)"}}

↑ ? ? ? ? ? ? ? ? ? ↑

input ? ? ? ? ? ? ?arg

最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點,簡書系信息發(fā)布平臺,僅提供信息存儲服務。

推薦閱讀更多精彩內(nèi)容

  • AngularJS是什么?AngularJs(后面就簡稱ng了)是一個用于設計動態(tài)web應用的結(jié)構(gòu)框架。首先,它是...
    200813閱讀 1,631評論 0 3
  • Angular面試題 一、ng-show/ng-hide與ng-if的區(qū)別? 第一點區(qū)別是,ng-if在后面表達式...
    w_zhuan閱讀 5,564評論 0 26
  • 1 1.認識AngularJSMVx概念Angular是什么擴展了HTML的功能顛覆性、可擴展為什么使用angul...
    codewa閱讀 944評論 1 3
  • 1、angularjs的幾大特性是什么? 雙向數(shù)據(jù)綁定、依賴注入、模板、指令、MVC/MVVM 2、列舉幾種常見的...
    2e9a10d418ab閱讀 1,381評論 0 10
  • ng-model 指令ng-model 指令 綁定 HTML 元素 到應用程序數(shù)據(jù)。ng-model 指令也可以:...
    壬萬er閱讀 889評論 0 2