angularjs學習筆記

瓜瓜東西發表於2014-12-19


Cannot find module 'mkdirp'
檢視nodejs已經有的外掛和版本
npm install –g mkdirp 安裝方法
nodejs 練習

1檢視nodejs版本命令
node -v
node --version

2 神祕雙大括號{{}} ng-model /input雙向繫結
{{}}
3 angular的使用例項
<!doctype html>
<html ng-app>
    <head>
        <script src="angular.js"></script>
      
		<script >
			function InvoiceCntl($scope) {
				$scope.qty = 1;
				$scope.cost = 19.95;
			}
		</script>
    </head>
    <body>
        <div ng-controller="InvoiceCntl">
            <b>Invoice:</b>
            <br>
            <br>
            <table>
                <tr><td>Quantity</td><td>Cost</td></tr>
                <tr>
                    <td><input type="integer" min="0" ng-model="qty" required ></td>
                    <td><input type="number" ng-model="cost" required ></td>
                </tr>
            </table>
            <hr>
            <b>Total:</b> {{qty * cost | currency}}
        </div>
    </body>
</html>
4 比較好的 url地址 angularjs
http://www.360doc.com/content/14/0414/15/14416931_368816305.shtml
5 資料繫結問題 ng-app+ng-model+ng-bind
ng-init 是用來初始化用的
ng-repeat 實現了迴圈
<div ng-app="">
 
<p>在輸入框中嘗試輸入:</p>
<p>姓名: <input type="text" ng-model="name"></p>
<p ng-bind="name"></p>
<input type="text" ng-model="aaa">
<p ng-bind="aaa"></p>
</div>

<script src="//www.w3cschool.cc/try/angularjs/1.2.5/angular.min.js"></script>

6 過濾器
currency /uppercase/lowercase  orderBy:'name' filter:name 
7 json
 $http.get().success(function(res){xxxx});
8 ng-show true/false
   ng-disabled true;
9 事件 
ng-hide="true"
ng-click="count=count+1"
10 模組使用方法
<div ng-app="pp" ng-controller="ppc">
{{p.name+""+p.age}}
</div>
<script>
var a = angular.module("pp",[]);
   a.controller("ppc",function($scope){

  $scope.p={
   name:"a",
 age:"b",
}
});
11 

<!--
<form novalidate>
<input type="text" ng-model="dd.f">
<input type="text" ng-model="dd.l">
<button ng-click="set()">reset</button>
</form>
-->

$scope.m={f:"f",l:"l"};
$scope.set=function(){
$scope.dd=angular.copy($scope.m);
}    
$scope.set();





相關文章