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]这么重量级的 ...
随机推荐
- HDU 4309 Contest 1
最大流建图.开始以为旧桥有1000座,没敢用枚举,后来看看题目发现了只是十二座.枚举桥的状态没问题. 对于隧道的容量W,可以虚拟出第三个结点表示,如u->v.增加一个点p,u->p(INF ...
- [Python + Unit Testing] Write Your First Python Unit Test with pytest
In this lesson you will create a new project with a virtual environment and write your first unit te ...
- Creating new web parts kentico 10
Developing web parts https://docs.kentico.com/k10/custom-development/developing-web-parts Web parts ...
- ThinkPHP新建控制器
ThinkPHP新建控制器 一.效果图 二.步骤 1.新建控制器文件 2.编写控制器文件 3.访问控制器 三.注意事项
- xBIM 基础12 WeXplorer xViewer的导航、相机、剖切、隐藏等操作
系列目录 [已更新最新开发文章,点击查看详细] 本篇将学习xViewer的导航,剪切和隐藏.这应该足以使用户能够通过所有缩放,平移,轨道运行和隐藏可能的障碍物来检查建筑物内部.点击这里可以看到 ...
- VC6之MAP文件生成及格式
文件生成方式: 在 VC 中,我们可以按下 Alt+F7 ,打开“Project Settings”选项页,选择 C/C++ 选项卡,并在最下面的 Project Options 里面输入:/Zd , ...
- Java Swing 托盘闪烁Demo实例
桌面程序当中,托盘显示是一个常用的功能. C#的WinForm程序要实现托盘是挺轻松的,而Java Swing要实现这个功能虽然也不难, 但是由于Java Swing开发者或许没有C#多,所以看到很多 ...
- 线程进阶:多任务处理(17)——Java中的锁(Unsafe基础)
在网络层,互联网提供所有应用程序都要使用的两种类型的服务,尽管目前理解这些服务的细节并不重要,但在所有TCP/IP概述中,都不能忽略他们: 无连接分组交付服务(Connectionless Packe ...
- 网页字体助手 WebFont Helper
网页字体助手 是 Windows 平台离线的网页字体生成辅助工具.核心功能,采用 python 编写. WebFont Helper 功能特色 生成字体子集(即提取用到的字符生成字体,或者大家所说的字 ...
- Android 开发环境安装配置手册
本文指导,如何一步步搭建Android开发平台. 1 下载软件 n JDK 1.5+ 到 http://java.sun.com/javase/downloads/index.jsp 下载 n ...