ng-book 1DataBinding and First AngularJS Web Application
来源:互联网 发布:淘宝一元秒杀网 编辑:程序博客网 时间:2024/05/16 19:51
第一种方法:代码在一个clock.html,独立实现
<!doctype html>
<html ng-app>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.0-rc.2/angular.js"></script>
</head>
<body>
<div ng-controller="MyController">
<h1>Hello {{ clock }}!</h1>
</div>
<script type="text/javascript">
function MyController($scope) {
$scope.clock = new Date();
var updateClock = function() {
$scope.clock = new Date();
};
setInterval(function() {
$scope.$apply(updateClock);
}, 1000);
updateClock();
};
</script>
</body>
</html>
第二种方法:代码分两部分,第一部分view:_clockhtml,第二部分module:app.js
_clock.html
<html ng-app="app">
<head>
<script src="https://ajax.googleapis.com/ajax/
libs/angularjs/1.2.5/angular.js"></script>
</head>
<body>
<div ng-controller="MyController">
<h1>Hello {{ clock.now }}!</h1>
</div>
<script type="text/javascript" src="app.js"></script>
</body>
</html>
////////////////////////////////////////////////////////////////////////////////////////////////////////
app.js
app=angular.module("app",[]);
app.controller('MyController',function($scope){
$scope.clock = {
now: new Date()
};
var updateClock = function() {
$scope.clock.now = new Date()
};
setInterval(function() {
$scope.$apply(updateClock);
}, 1000);
updateClock();
})
- ng-book 1DataBinding and First AngularJS Web Application
- angularJS-1:ng-repeat用法
- bpel book and tool(1)
- EF Database First with ASP.NET MVC: Creating the Web Application and Data Models开发遇到问题的解决办法
- web application exploits and defenses
- MY FIRST COREWAR BOOK
- angularjs ng-show ng-hidden
- Grid Application Development: e-Science Application using GT-4 and Web Services (1)
- ng-class $first
- AngularJS ng-click bug
- AngularJS ng-include
- angularjs ng-repeat
- AngularJS ng-class
- Angularjs ng-options用法
- angularjs ng-repeat
- AngularJS ng-class用法
- AngularJS ng-model directive
- AngularJS ng-cloak 指令
- fedramp
- web框架之Spring-MVC环境搭建
- Android TextView中 字体加粗方法
- 手把手图文教你eclipse下如何配置tomcat
- 用sbt创建eclipseIDE项目
- ng-book 1DataBinding and First AngularJS Web Application
- java多线程池实例
- 那个房间换个房间空间
- android 添加新的键值,自定义按键
- Linux下查询单个进程I/O信息
- "黑马程序员" 用java语言打印三角形
- 求 最小公倍数 与 最大公约数
- ubuntu 安装输入法
- 使用MyBatis_Generator生成Dto、Dao、Mapping