码迷,mamicode.com
首页 > Web开发 > 详细

该怎么写Angular JS

时间:2015-08-02 21:33:09      阅读:116      评论:0      收藏:0      [点我收藏+]

标签:


<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监视一个表达式,当这个表达式发生变化时就会调用一个回调函数
        $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>

该怎么写Angular JS

标签:

原文地址:http://www.cnblogs.com/ruimeng/p/4696706.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!