【AngularJs-模块篇-Form篇】
1、模块
<!doctype html> <html lang="en-US" ng-app="myApp"> <head> <meta charset="UTF-8"> <title></title> <!-- <script src="http://code.angularjs.org/angular-1.0.1.min.js"></script> --> <script src="../angular.min.js"></script> <script type="text/javascript"> var myAppModule=angular.module(‘myApp‘,[]) ; myAppModule.controller(‘TextController‘,function($scope){ var someText={}; someText.message="you have started"; $scope.someText=someText; }) ; //ng-bind和{{someText}}具有相同功能 </script> </head> <body ng-controller="TextController"> <p ng-bind="someText"></p> <input type="text" value="{{someText.message}}"> </body> </html>
2、Form控件绑定(未完成)
<!doctype html> <html lang="en-US" ng-app="myApp"> <head> <meta charset="UTF-8"> <title></title> <!-- <script src="http://code.angularjs.org/angular-1.0.1.min.js"></script> --> <script src="../angular.min.js"></script> <script type="text/javascript"> var myAppModule=angular.module(‘myApp‘,[]) ; myAppModule.controller(‘StartUpController‘,function($scope){ $scope.computeNeeded=function(){ $scope.needed=$scope.startingEstimate*10; }; $scope.requestFunding=function(){ window.alert("sorry,please get moure cutomers first"); }; $scope.reset=function(){ $scope.startingEstimate=0; } ; }) ; </script> </head> <body> <form ng-submit="requestFunding()" ng-controller="StartUpController"> Starting:<input ng-change="computeNeeded()" ng-model="startingEstimate"> Recommendation:{{needed}} <button>Fund my startup!</button> <button ng-click="reset()" value="reset">reset</button> </form> </body> </html>
郑重声明:本站内容如果来自互联网及其他传播媒体,其版权均属原媒体及文章作者所有。转载目的在于传递更多信息及用于网络分享,并不代表本站赞同其观点和对其真实性负责,也不构成任何其他建议。