该怎么写Angular JS
2015-08-02 20:52
543 查看
<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>
<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
- SSH和EXTJS 之旅开始
- Chrome 控制台 如何调试 javascript
- 使用DWR实现JS调用服务端Java代码
- 使用DWR实现JS调用服务端Java代码
- 使用DWR实现JS调用服务端Java代码
- Javascript-基础知识(6)
- Angular JS的模块依赖
- Angular JS的依赖注入
- Javascript-基础知识(5)
- javascript设计模式之Mediator(中介者)模式
- 使用js编写一个计算器
- Javascript-基础知识(4)
- ExtJS Trigger
- Javascript-基础知识(3)
- 2015.8.2js-19(完美运动框架)
- JavaScript-基本知识(2)
- JavaScript对象的使用
- Javascript-基础知识(1)
- ABP之Javascript生成