angularjs ng-app
<!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的更多相关文章
- 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 ...
- 实践分享:开始用Cordova+Ionic+AngularJS开发App
http://www.cocoachina.com/webapp/20150707/12395.html 本文是一篇关于我本人在使用Cordova+Ionic以及AngularJS开发移动App的过程 ...
- 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 ...
- AngularJS - contorller app module
<!DOCTYPE html> <html> <head> <meta http-equiv="Content-Type" content ...
- Part 15 AngularJS ng init directive
The ng-init directive allows you to evaluate an expression in the current scope. In the following e ...
- part 4 AngularJS ng src directive
- [AngularJS - app] AngularJS Location-picker app
From: http://rangle.io/blog/two-ways-to-build-a-location-picker-for-a-mobile-angularjs-application/ ...
- AngularJS的学习笔记(一)
声明:单纯作为我自己的学习笔记,纯是为了自己学习,上面的话都是从各处粘贴,如有冒犯,请原谅我这个小菜鸟~ AngularJS使用了不同的方法,它尝试去补足HTML本身在构建应用方面的缺陷. 使用双大括 ...
- [AngularJS] AngularJS系列(1) 基础篇
目录 什么是AngularJS? 为什么使用/ng特性 Hello World 内置指令 内置过滤器 模块化开发 一年前开始使用AngularJS(以后简称ng),如今ng已经出2了.虽说2已完全变样 ...
- 从angularJS看MVVM
javascript厚积薄发走势异常迅猛,导致现在各种MV*框架百家争雄,MVVM从MVC演变而来,为javascript注入了全新的活力.我工作的业务不会涉及到angularJS[ng]这么重量级的 ...
随机推荐
- 创业笔记-Node.js入门之阻塞与非阻塞
阻塞与非阻塞 正如此前所提到的,当在请求处理程序中包括非阻塞操作时就会出问题.但是,在说这之前,我们先来看看什么是阻塞操作. 我不想去解释“阻塞”和“非阻塞”的具体含义,我们直接来看,当在请求处理程序 ...
- HDUOj 看病要排队 优先队列的使用 题目1873
STL优先队列的具体描写叙述 http://blog.csdn.net/yueloveme/article/details/47106639 题目地址:http://acm.hdu.edu.cn/s ...
- 对Shell几个冷知识的总结(IFS,数组,替换,分割,查找)
IFS: 对IFS的用处直接进行说明,详细IFS是干什么的...自行谷歌 首先创建一个 "a a",和"a"的文件: 然后我们 ls查看一下: --> l ...
- No connection could be made because the target machine actively refused it [::1]:808
No connection could be made because the target machine actively refused it [::1]:808 1.首先查看端口占用情况, 在 ...
- Authentication in asp.net
https://docs.microsoft.com/en-us/aspnet/web-forms/overview/older-versions-security/introduction/an-o ...
- Linux命令详解./configure,make,make install的作用
这些都是典型的使用GNU的AUTOCONF和AUTOMAKE产生的程序的安装步骤. ./configure是用来检测你的安装平台的目标特征的.比如它会检测你是不是有CC或GCC,并不是需要CC或GCC ...
- hihocoder1415 重复旋律3
思路: 扫一遍height 判一下即可 //By SiriusRen #include <cstdio> #include <cstring> #include <alg ...
- zookeeper的选举机制
1)半数机制:集群中半数以上机器存活,集群可用.所以zookeeper适合装在奇数台机器上. 2)Zookeeper虽然在配置文件中并没有指定master和slave.但是,zookeeper工作时, ...
- oracle-常见的执行计划(一)
一.表访问方式 CBO基础概念中有讲到,访问表的方式有两种:全表扫描和ROWID扫描. 全表扫描的执行计划:TABLE ACCESS FULL ROWID扫描对应执行计划:TABLE ACCESS B ...
- (转)js document.all的用法
document.all用法 一. document.all是页面内所有元素的一个集合.例如: document.all(0)表示页面内第一个元素 二.document.all可以判断浏览器 ...