• AngularJS学习(一)


    参考文章:http://blog.csdn.net/dc_726/article/details/17010325

    1、HelloWorld篇

      1.1 环境

        下载:angular-1.2.5min.js

      1.2 源代码

    <!doctype html>
    <html ng-app>
        <head>
            <script src="angular-1.2.5.min.js"></script>
        </head>
        <body>
            hello {{'world'}}!
        </body>
    <html

      1.3 运行结果

      

    2、双向数据绑定

      2.1 源代码

    <!doctype html>
    <html ng-app>
        <head>
            <script src="angular-1.2.5.min.js"></script>
        </head>
        <body>
            Your name:<input type="text" ng-model="yourname" placeholder="world">
            <hr>
            hello {{yourname || 'world'}}!
        </body>
    <html

      2.2 运行结果

      

      2.3、说明

        文本输入指令<input ng-model="yourname"/> 绑定一个叫yourname的模型变量

        双大括号标记yourname模型变量添加到问候语文本。

        你不需要为改应用另外注册一个事件监听器或添加事件处理程序!

        现在试着在输入框中输入您的名称,您键入的名称将立即更新显示在问候语中,这就是AngularJs的双向绑定概念。输入框的任何更改都会立即反应到模型变量(一个方向)模型变量的任何更改都会立即反映到问候语文本中(另一个方向)

      

    作者:BestNow
    出处:http://www.cnblogs.com/BestNow/
    本文版权归作者和博客园共有,欢迎转载,但未经作者同意必须保留此段声明,且在文章页面明显位置给出原文连接,否则保留追究法律责任的权利。
  • 相关阅读:
    有什么样的博客手机客户端
    v2ex thread record
    Screengrab! firefox截图插件
    现在看一次咳嗽感冒就差不多要1k了,恐怖
    海归人才网
    LinkedIn公司实现的实时搜索引擎Zoie
    xipian的php中文分词
    海归人才网
    idea
    snagit number stampsgood for ppt
  • 原文地址:https://www.cnblogs.com/tianxue/p/3896673.html
Copyright © 2020-2023  润新知