Angularjs 控制器
来源:互联网 发布:随意画线软件 编辑:程序博客网 时间:2024/04/30 00:11
<!DOCTYPE html><html><head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <head> <body><div ng-app="" ng-controller="personController">名: <input type="text" ng-model="person.firstName"><br/>姓: <input type="text" ng-model="person.lastName"><br/><br/>姓名: {{person.firstName + " " + person.lastName}}</div><script>function personController($scope) { $scope.person = { firstName: "Shawn", lastName: "Dong" };}</script><script src="http://apps.bdimg.com/libs/angular.js/1.2.16/angular.min.js"></script></body></html>
进一步
<!DOCTYPE html><html><head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <head> <body><div ng-app="" ng-controller="personController">名: <input type="text" ng-model="person.firstName"><br>姓: <input type="text" ng-model="person.lastName"><br><br>姓名: {{person.fullName()}}</div><script>function personController($scope) { $scope.person = { firstName: "Shawn", lastName: "Dong", fullName: function() { var x; x = $scope.person; return x.firstName + " " + x.lastName; } };}</script><script>src="http://apps.bdimg.com/libs/angular.js/1.2.16/angular.min.js"></script></body></html>
带有方法的控制器
<!DOCTYPE html><html><head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <head> <body><div ng-app="" ng-controller="personController">名: <input type="text" ng-model="person.firstName"><br>姓: <input type="text" ng-model="person.lastName"><br><br>姓名: {{fullName()}}</div><script>function personController($scope) { $scope.person = { firstName: "Shawn", lastName: "Dong", }; $scope.fullName = function() { var x; x = $scope.person; return x.firstName + " " + x.lastName; };}</script><script>src="http://apps.bdimg.com/libs/angular.js/1.2.16/angular.min.js"></script></body></html>
进一步
test.html
<div ng-app="" ng-controller="namesController"><ul> <li ng-repeat="x in names"> {{ x.name + ', ' + x.country }} </li></ul></div><script src="http://apps.bdimg.com/libs/angular.js/1.2.16/angular.min.js"></script><script src="test.js"></script>
test.js
function namesController($scope) { $scope.names = [ {name:'11',country:'c1'}, {name:'22',country:'c2'}, {name:'33',country:'c3'} ];}
0 0
- AngularJS控制器
- Angularjs 控制器
- Angularjs 控制器
- AngularJS 控制器
- AngularJS 控制器
- AngularJS控制器
- AngularJS 控制器
- AngularJS 控制器
- angularJS-----控制器
- AngularJS 控制器
- AngularJS 控制器
- angularJS-控制器
- AngularJS 控制器
- AngularJS 控制器
- AngularJS控制器
- AngularJS控制器
- AngularJS控制器
- AngularJS 控制器
- 第2周-项目5-数组作数据成员-工资类(文件读取)
- xstream实现xml与Object之间的自如转换
- Implement strStr()
- 新手对于iPhone开发环境等入门问题解答汇总
- getHibernateTemplate()
- Angularjs 控制器
- SGU - 169 - Numbers (找规律)
- 第2周-项目5-数组作数据成员-工资类(多文件组织)
- 请求的内容似乎是脚本,因而将无法由静态文件处理程序来处理解决方案 服务器配置错误
- 编译脚本
- nyoj 32 组合数(DFS)
- SNMP协议详解
- CSS 实现表格中文字不换行,超长部分显示省略号
- poj1276