AngularJS中的控制器示例_3
<!doctype html>
<html ng-app="myApp">
<head>
<script src="C:\\Users\\yuli\\Desktop\\bower_components\\angularjs\\angular.js"></script>
<script type="text/javascript">
var myModule = angular.module('myApp', []);
myModule.controller('MyController', function ($scope, $timeout) {
var updateClock = function() {
$scope.clock = new Date();
$timeout(function() {
updateClock();
}, 1000);
};
updateClock(); $scope.a_click = function (msg){
console.log(msg);
}
$scope.value = 1;
$scope.add = function (n){
$scope.value += n;
} $scope.clear = function(){
$scope.value = 0;
}
}); myModule.run(function($rootScope){
$rootScope.rootValue = -1;
$rootScope.add_n = function(n){
$rootScope.rootValue += n;
};
});
</script>
</head>
<body>
<div ng-controller="MyController">
<h1>Hello {{ clock }}!</h1>
这是AngularJS的测试程序。
<a href="" ng-click="a_click('hello')">click me console.log message.</a>
<a href="" ng-click="add(2)">add 2.</a>
<input type="text" ng-model="value"/> <br />
<a href="" ng-click="clear()">clear.</a>
<br />
<input type="text" ng-model="rootValue"/>
<a href="" ng-click="add_n(value)">add n.</a>
</div>
</body>
</html
AngularJS中的控制器示例_3的更多相关文章
- AngularJS中的控制器示例_2
<!doctype html> <html ng-app="myApp"> <head> <script src="C:\\Us ...
- AngularJS中的控制器示例
<!doctype html> <html ng-app="myApp"> <head> <script src="C:\\Us ...
- AngularJS中的控制器和作用域
欢迎大家指导与讨论 : ) 一. 作用域的事件传播 一 . 1 修改的传播 关于作用域最重要的一点是修改会通过事件传播下去,自动更新所以依赖的数据值,即使是通过行为产生的.简而言之,就是即时您只修 ...
- angularJS中如何写控制器
angularJS中的控制器是一个函数,用来向视图作用域中添加额外的功能,我们用它来给作用域对象设置初始状态,并添加自定义行为 当我们在页面上创建一个新的控制器时,angularJS会生成并传递一个新 ...
- AngularJS中控制器继承
本篇关注AngularJS中的控制器继承,了解属性和方法是如何被继承的. 嵌套控制器中属性是如何被继承的? ==属性值是字符串 myApp.controller("ParentCtrl&qu ...
- AngularJS入门基础——控制器
AngularJS中的控制器是一个函数,用来向视图的作用域添加额外的功能.我们用它来给作用域对象设置初始状态,并添加自定义行为. AngularJS同其他JavaScript框架最主要的一个区别就是, ...
- angularJS中控制器和作用范围
$scope是$rootScope的子作用域控制对象,$rootScope的id为1,其他的为2,3,4... 不同的控制器之间,所对应的作用域控制对象$scope,之间是相互隔离的,如果要共享数据, ...
- AngularJS中控制器之间通信方法
在同个angular应用的控制器之间进行通信可以有很多种不同的方式,本文主要讲两种: 基于scope继承的方式和基于event传播的方式 基于scope继承的方式 最简单的让控制器之间进行通信的方法是 ...
- AngularJS学习--- AngularJS中XHR(AJAX)和依赖注入(DI) step5
前言:本文接前一篇文章,主要介绍什么是XHR,AJAX,DI,angularjs中如何使用XHR和DI. 1.切换工具目录 git checkout -f step- #切换分支 npm start ...
随机推荐
- 程序被送入后台后,向 iOS 借时间,完成长期任务-备
12.2.2. 方案 使用UIApplication的beginBackgroundTaskWithExpirationHandler: 实例方法.在你完成任务后,调用UIApplication的en ...
- (转)Oracle Data Guard配置
data guard配置的条件1.在主库和从库的所有机器上必须安装同一个版本的Oracle企业版.2.主库必须运行在归档模式下.3.主库和从库的操作系统必须一样(允许版本不同),从库可以使用与主库不同 ...
- BZOJ1211: [HNOI2004]树的计数
1211: [HNOI2004]树的计数 Time Limit: 10 Sec Memory Limit: 162 MBSubmit: 1245 Solved: 383[Submit][Statu ...
- requireJS define require
原文地址:http://blog.csdn.net/xiaogou56a/article/details/21340213 define 用来定义模块 require 用来加载模块 1 因为定义一个模 ...
- [Matlab] Attempt to execute SCRIPT *** as a function
Attempt to execute SCRIPT *** as a function 问题: 在运行MATLAB程序的时候,出现如题的报错. 原因: 在系统中,现有的.m文件有的与***函数重名,所 ...
- 分页标签:pager-taglib使用指南
一简介, Pager-taglib,支持多种风格的分页显示.实际上她是一个Jsp标签库,为在JSP上显示分页信息而设计的一套标签,通过这些标签的不同的组合,会形成多种不一样的分页页面,风格各异,她自带 ...
- poj 2046 Gap(bfs+hash)
Description Let's play a card game called Gap. You have cards labeled with two-digit numbers. The fi ...
- hdu 2817 A sequence of numbers(快速幂)
Problem Description Xinlv wrote some sequences on the paper a long time ago, they might be arithmeti ...
- pyqt时间
# -*- coding: utf-8 -*-__author__ = 'Administrator'from PyQt4 import QtCore, QtGui class Help(QtGui. ...
- 原生javascript 改写的tab选项卡
<!--css部分--> <style> *{ margin: 0; padding: 0; } ul,li{ list-style: none } .tabbox{ widt ...