美文网首页
angularjs尘埃及入门

angularjs尘埃及入门

作者: Antus | 来源:发表于2019-08-04 16:07 被阅读0次

    <!DOCTYPE html>

    <html>

    <head>

    <meta charset="utf-8">

    <script src="https://cdn.staticfile.org/angular.js/1.4.6/angular.min.js"></script>

    </head>

    <body>

    <div ng-app="">

      <p>名字 : <input type="text" ng-model="name"></p>

      <h1>Hello {{name}}</h1>

    </div>

    </body>

    </html>


    备注:

    1、ng-app=" "  定义angularJS的使用范围;

    ng-app 指令告诉 AngularJS,<div>元素是 AngularJS 应用程序 的"所有者"。

    2、ng-init="变量=值;变量='值'"  初始化变量的值,有多个变量时,中间用分号隔开;

    3、ng-model="变量"  定义变量名;

    ng-model 指令把输入域<text>的值绑定到应用程序变量 name

    4、ng-bind="变量"  绑定变量名,获取该变量的数据。这里的变量就是第3条的变量名。但是一般都用双重花括号来获取变量的值,比如:{{变量}}。


    相关文章

      网友评论

          本文标题:angularjs尘埃及入门

          本文链接:https://www.haomeiwen.com/subject/nkofkctx.html