$scope对象就是一个普通的JavaScript对象,我们可以在其上随意修改或添加属性。
$scope对象在AngularJS中充当数据模型,但与传统的数据模型不一样,$scope并不负责处
理和操作数据,它只是视图和HTML之间的桥梁,它是视图和控制器之间的胶水。
$scope的所有属性,都可以自动被视图访问到

 <!DOCTYPE html>
<html ng-app = "myApp">
<head>
<title>Simple app</title>
</head>
<body>
<div ng-controller = "MyController">
<h1>Hello {{name}}</h1>
</div>
<script type="text/javascript" src = "js/angular.js"></script>
<script type="text/javascript" src = "js/app.js">
</script>
</body>
</html>

上面的ng-app对应下面angular.module("myApp", [])中的命名,{{name}}放在$scope下声明变量

 var myApp = angular.module("myApp", [])

 myApp.controller('MyController', function($scope) {
$scope.name = "Ari";
});

随机推荐

  1. 【bzoj1738】[Usaco2005 mar]Ombrophobic Bovines 发抖的牛 Floyd+二分+网络流最大流

    题目描述 FJ's cows really hate getting wet so much that the mere thought of getting caught in the rain m ...

  2. Oracle数据库中心双活之道:ASM vs VPLEX

    Oracle数据库中心双活之道:ASM vs VPLEX 来源 https://www.cnblogs.com/wenjiewang/p/7460212.html 双活方案对比:ASM vs V-PL ...

  3. NOIP 2018 -The Wound-

    "一招不慎,满盘皆输" 如果这个盘是整整一年的OI生涯的话 那么"一招"一定就是NOIP了 Update 2019/4/6 剧变的一年 noip这个成绩意味着我 ...

  4. 洛谷3794:签到题IV——题解

    https://www.luogu.org/problemnew/show/P3794 题目见上. 有一个套路(虽然我到现在还不会),就是固定一个端点,二分查右端点. 显然这题的正解是O(nlogn) ...

  5. HDU 1715 大数java

    大菲波数 Time Limit: 1000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submis ...

  6. bzoj1178 [Apio2009]CONVENTION会议中心 区间dp+贪心

    [Apio2009]CONVENTION会议中心 Time Limit: 15 Sec  Memory Limit: 162 MBSubmit: 1130  Solved: 444[Submit][S ...

  7. bzoj 4900 [CTSC2017]密钥 模拟+乱搞

    题目:https://www.lydsy.com/JudgeOnline/problem.php?id=4900 #include<cstring> #include<cmath&g ...

  8. android中dip、dp、px、sp和屏幕密度

    1. dip: device independent pixels(设备独立像素). 不同设备有不同的显示效果,这个和设备硬件有关,一般我们为了支持WVGA.HVGA和QVGA 推荐使用这    这个 ...

  9. SNS应用好友动态Feed模块设计

    转载自:http://libo93122.blog.163.com/blog/static/122189382012112145728902/ 备注:找不到原作者了. 现在大部分SNS网站都有一个功能 ...

  10. (转)Django发送html邮件

    本文转自http://blog.csdn.net/yima1006/article/details/8991145 send_mail(subject, message, from_email, re ...