初学angular.js

<!doctype  html>
<html ng-app>
   <head>
    <meta charset="utf-8" />
    <title>angular</title>
    <script src="angular.js" /></script>
   </head>
   <body>
     Your name: <input type="text" ng-model="yourname" placeholder="World">
      Hello {{yourname || 'World'}}!
      Hello {{'world'}}
   </body>
</html>

引入angular.js 在html里面标记ng-app。输出的结果就是hello world

angular的双向绑定概念,绑定ng-model="yourname",plarceholder为默认值。

hello {{'world'}}的输入结果为hello world.

注意,使用双大括号标记{{}}的内容是问候语中绑定的表达式,这个表达式是一个简单的字符串‘World’。嘿嘿,这是官方的写法。我直接拿过来了。因为我这也是初次研究,先记下来吧。

hello {{yourname || 'world'}} 的输出结果为:文本框内默认为world时,输出的是hello world.

自己重新输入的话,就会实时更新为您所输入的文字,好神奇。

接下来一起学习angular.js.

posted @ 2015-03-06 11:37  吉米小绵羊  阅读(130)  评论(0编辑  收藏  举报