javascript
该怎么写Angular JS
<html ng-app>
<head>
??? <title>表單</title>
??? <script type="text/javascript" src="angular.min.js"></script>
??? <script type="text/javascript">
??? function StartUpController($scope) {
??????? $scope.funding = {startingEstimate:0};
??????? computeNeeded = function() {
??????????? $scope.funding.needed = $scope.funding.startingEstimate * 10;
??????? };
??????? $scope.$watch('funding.startingEstimate',computeNeeded);//watch監(jiān)視一個(gè)表達(dá)式,當(dāng)這個(gè)表達(dá)式發(fā)生變化時(shí)就會(huì)調(diào)用一個(gè)回調(diào)函數(shù)
??????? $scope.requestFunding = function() {
??????????? window.alert("Sorry,please get more customers first.")
??????? };
??? }
??? </script>
</head>
<body>
??? <form ng-submit="requestFunding()" ng-controller="StartUpController">? //ng-submit
??????? Starting: <input ng-change="computeNeeded()" ng-model="funding.startingEstimate">
??????? Recommendation: {{funding.needed}}
??????? <button>Fund my startup!</button>
??? </form>
</body>
</html>
轉(zhuǎn)載于:https://www.cnblogs.com/ruimeng/p/4696706.html
總結(jié)
以上是生活随笔為你收集整理的该怎么写Angular JS的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 怎么把pdf文件转换成可编辑的word文
- 下一篇: JavaScript采用append添加