看angularjs項目的一些知識記錄

這兩天項目組長在安排我學習用angularjs+Echarts作的項目代碼,邊看邊記錄吧,給本身留個總結html

1.Angularjs中UI Router文檔jquery

2.Angularjs中Material的使用git

3.requirejs文檔angularjs

 

幾個指令特色記錄github

1.ng-value中能夠寫表達式web

<input type="text" ng-value="price*num"/>

2.當咱們點擊checkbox 選中複選框時,ng-model 的綁定默認值是true,取消選中時爲false.json

若是咱們須要獲取的值爲字符串或者數字,那麼就須要用到 ng-true-valueng-false-valueapp

<input ng-model="checkboxModel" type="checkbox" ng-true-value=" 1 " ng-false-value="0">

3.angular中的工具函數:ide

    ①、遍歷angular.forEach(data,function(el,i){})函數

    ②、轉大小寫

    ③、深拷貝:angular.copy:

    ④、處理json:angular.toJson(json對象轉字符串)/angular.fromJson(json字符串轉對象)

    ⑤、擴展對象:angular.extend(dst, src),把src中能夠枚舉的屬性所有封裝到dst對象上面

 

4.ng-click綁定事件,事件執行完後會進行髒檢查;用js或jquery綁定事件,須要綁定$apply()函數纔會執行髒檢查

{{name}}
<button ng-click="change()">點擊</button>
<hr>
{{name}}
<button id="btn">獲取</button>

$scope.name="張飛";
$scope.change=function(){
    $scope.name="劉備";
}

var btn=document.getElementById('btn');
btn.onclick=function(){
    $scope.name='關羽';
    $scope.$apply();
}

 5.$scope綁定的數據到頁面上都會轉換成字符串,若是想把標籤字符串轉換成標籤,須要用到$sce服務:

.controller("moduleCtrl",function($scope,$sce){
    $scope.name=$sce.trustAsHtml("<h1 style='color:red;'>張飛</h1>");
})

頁面元素須要寫成

<div ng-bind-html="name"></div>
相關文章
相關標籤/搜索