Concept:
JavaScript-based ' client application framework ' enables us to develop Web applications more quickly and easily. Development for CRUD or spa single-page Web sites (frequent interaction of front-end data)
Scope:
$scope: Local
$rootScope: Global
bidirectional data binding: MVVM
$timeout usage similar to settimeout
But $timeout will change the value in the view
Ng-click similar to onclick
Ng-model
Listener: (Monitor data changes)
Three parameters:
objects to listen to
callback function----> has two parameters (new value, old value)
true: whether to listen in depth
Instance:
<!doctype html>
<meta charset= "UTF-8" >
<title>angularjs First Knowledge </title>
<!--introduce angularjs files--
<script type= "Text/javascript" src= "Angular.min.js" ></script>
<script type= "Text/javascript" >
var Phonecatapp =angular.module (' Phonecatapp ', []);
Phonecatapp.controller (' Phonelistctrl ', function ($scope) {
$scope. huawei={
' price ': 1499,
' num ': 1,
' fre ': 20
};
$scope. max = function () {
return $scope. huawei.price* $scope. Huawei.num;
}
$scope. $watch ($scope. Max,function (newval,oldval) {
newval>=100? $scope. huawei.fre=0: $scope. huawei.fre=20;
},true);
})
</script>
<body>
<div ng-controller= ' Phonelistctrl ' >
<p> Price: <input type= "text" ng-model= ' Huawei.price '/></p>
<p> Number: <input type= "text" ng-model= ' Huawei.num '/></p>
<p> Fee: <span></span>{{max () | Currency: ' ¥ '}}</p>
<p> Freight: <span></span>{{huawei.fre | Currency: ' ¥ '}}</p>
<p> total: <span></span>{{max () +huawei.fre| currency: ' ¥ '}}</p>
</div>
</body>
This article is from the "12897581" blog, please be sure to keep this source http://12907581.blog.51cto.com/12897581/1928368
Angularjs First Knowledge