<!DOCTYPE HTML>
<html ng-app> //ng-app是初始化指令,整个页面都会被angularjs解析,写在div或者其他标签上表示只是局部的div和标签里面使用angularjs解析,其余的不用anguarjs解析。
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>无标题文档</title>
<script src="angular.min.js"></script>
<script> function Aaa($scope,$timeout){
$scope.name = 'hello';
setTimeout(function(){
$scope.name = 'hi';//setTimeout这个定时器不能刷新name的值
},);
$timeout(function(){
$scope.name = 'hi';//$timeout是angularjs的定时器才能使name值刷新
},); $scope.show = function(){
$scope.name = 'hi';
}; } </script>
</head> <body>
//ng-controller是控制器
<div ng-controller="Aaa" ng-click="name='hi'"> click函数改变name的值
<div ng-controller="Aaa" ng-click="show()"> 作用同上
<p>{{name}}</p>
</div> </body>
</html>
<!DOCTYPE HTML>
<html ng-app>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>无标题文档</title>
<script src="angular.min.js"></script>
<script> function Aaa($scope,$timeout){
$scope.name = 'hello';
}
</script>
</head> <body>
<div ng-controller="Aaa">
<input type="text" ng-model="name"> 输入框改变标签p也改变。
<p>{{name}}</p>
</div>
</body>
</html>
<!DOCTYPE HTML>
<html ng-app>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>无标题文档</title>
<script src="angular.min.js"></script>
<script> function Aaa($scope,$timeout){
$scope.iphone = {
money : ,
num : ,
fre :
};
$scope.sum = function(){
return $scope.iphone.money * $scope.iphone.num;
}; /*$scope.$watch('iphone.money',function(newVal,oldVal){
console.log(newVal);
console.log(oldVal);
},true);*/ $scope.$watch($scope.sum,function(newVal,oldVal){ //$watch监听数据的变化
//console.log(newVal);
//console.log(oldVal);
$scope.iphone.fre = newVal >= ? : ;
});
} </script>
</head> <body> <div ng-controller="Aaa">
<p>价格:<input type="text" ng-model="iphone.money"></p>
<p>个数:<input type="text" ng-model="iphone.num"></p>
<p>费用:<span>{{ sum() | currency:'¥' }}</span></p> currency是过滤器
<p>运费:<span>{{iphone.fre | currency:'¥'}}</span></p>
<p>总额:<span>{{ sum() + iphone.fre | currency:'¥'}}</span></p>
</div> </body>
</html>

angularjs ng-app的更多相关文章

  1. AngularJS Front-End App with Cloud Storage Tutorial Part 1: Building a Minimal App in Seven Steps

    原文 : http://www.codeproject.com/Articles/1027709/AngularJS-Front-End-App-with-Cloud-Storage-Tutoria ...

  2. 实践分享:开始用Cordova+Ionic+AngularJS开发App

    http://www.cocoachina.com/webapp/20150707/12395.html 本文是一篇关于我本人在使用Cordova+Ionic以及AngularJS开发移动App的过程 ...

  3. Part 6 AngularJS ng repeat directive

    ng-repeat is similar to foreach loop in C#. Let us understand this with an example. Here is what we ...

  4. AngularJS - contorller app module

    <!DOCTYPE html> <html> <head> <meta http-equiv="Content-Type" content ...

  5. Part 15 AngularJS ng init directive

    The ng-init directive allows you to evaluate an expression in the current scope.  In the following e ...

  6. part 4 AngularJS ng src directive

  7. [AngularJS - app] AngularJS Location-picker app

    From: http://rangle.io/blog/two-ways-to-build-a-location-picker-for-a-mobile-angularjs-application/ ...

  8. AngularJS的学习笔记(一)

    声明:单纯作为我自己的学习笔记,纯是为了自己学习,上面的话都是从各处粘贴,如有冒犯,请原谅我这个小菜鸟~ AngularJS使用了不同的方法,它尝试去补足HTML本身在构建应用方面的缺陷. 使用双大括 ...

  9. [AngularJS] AngularJS系列(1) 基础篇

    目录 什么是AngularJS? 为什么使用/ng特性 Hello World 内置指令 内置过滤器 模块化开发 一年前开始使用AngularJS(以后简称ng),如今ng已经出2了.虽说2已完全变样 ...

  10. 从angularJS看MVVM

    javascript厚积薄发走势异常迅猛,导致现在各种MV*框架百家争雄,MVVM从MVC演变而来,为javascript注入了全新的活力.我工作的业务不会涉及到angularJS[ng]这么重量级的 ...

随机推荐

  1. 2015 Multi-University Training Contest 6 hdu 5361 In Touch

    In Touch Time Limit: 8000/4000 MS (Java/Others)    Memory Limit: 131072/131072 K (Java/Others)Total ...

  2. org.apache.hadoop.ipc.Client: Retrying connect to server

    这个问题导致jps查看结点进程时发现找不到NodeManager或一段时间后消失,网上查找了很多博客,因hadoop版本不一样且出错的原因也可能不同,所以找了老半天. 步骤:jps --> 看l ...

  3. HDU 2841

    明显,当(X,Y)=1时,是可以看见的. 这题,记得POJ 上也有类似的一题... 不过比较奇怪的是,我以为会超时,因为范围达到了100000,但竟然直接枚举没超时.... #include < ...

  4. 玩转iOS开发 - Runloop 具体解释

    Runloop 具体解释

  5. scrapy研究探索(二)——爬w3school.com.cn

    下午被一个问题困扰了好一阵.终于使用还有一种方式解决. 開始教程二.关于Scrapy安装.介绍等请移步至教程(一)(http://blog.csdn.net/u012150179/article/de ...

  6. 葡萄城公布新版ActiveReports 9报表控件和报表server

    2014年11月10日---葡萄城宣布正式公布ActiveReports9,包含了三种报表模型:RDL报表.页面报表.区域报表.对于ActiveReports中的这个最新版本号中,我们专注于提高产品的 ...

  7. 山东理工oj--1912--IP地址(水题)

     IP地址 Time Limit: 1000ms   Memory limit: 65536K  有疑问?点这里^_^ 题目描述 2011年2月3日,国际互联网名称与数字地址分配机构(ICANN) ...

  8. VMware虚拟机ubuntu显示屏幕太小解决办法

    使用VMware安装的ubuntu虚拟机的显示屏幕太小,可以通过在VMware里安装"VMware Tool"插件解决,安装步骤记录一下. 1. 更改ISO文件路径 安装VMwar ...

  9. (八)统一配置中心-Config

    对于配置的重要性,我想我不用进行任何强调,大家都可以明白其重要性.在普通单体应用,我们常使用配置文件(application(*).properties(yml))管理应用的所有配置.这些配置文件在单 ...

  10. Mysql实战45讲 06讲全局锁和表锁:给表加个字段怎么有这么多阻碍 极客时间 读书笔记

    Mysql实战45讲 极客时间 读书笔记 Mysql实战45讲 极客时间 读书笔记 笔记体会: 根据加锁范围:MySQL里面的锁可以分为:全局锁.表级锁.行级锁 一.全局锁:对整个数据库实例加锁.My ...