• AngularJS 表达式


      AngularJS 使用表达式把数据绑定到HTML。

      AngularJS表达式写在双大括号内:{{ }};

      AngularJS表达式把数据绑定到HTML,这与ng-bind指令有异曲同工之妙;

      AngularJS将在表达式书写的位置 “输出” 数据;

      AngularJS表达式很想JavaScript表达式: 它们可以包含文字、运算符和变量。

      实例:

      AngularJS 数字

    <div ng-app="" ng-init="quantity=1;cost=5">  
        <p>总价: {{ quantity * cost }}</p>  
    </div>

    //使用ng-bind的相同实例: <div ng-app="" ng-init="quantity=1;cost=5"> <p>总价: <span ng-bind="quantity * cost"></span></p> </div>

      

      AngularJS 字符串

    <div ng-app="" ng-init="firstName='John';lastName='Doe'">  
        <p>姓名: {{ firstName + " " + lastName }}</p>  
    </div>
    
    // 使用ng-bind的相同实例: <div ng-app="" ng-init="firstName='John';lastName='Doe'"> <p>姓名: <span ng-bind="firstName + ' ' + lastName"></span></p> </div>

      

      AngularJS 对象

    <div ng-app="" ng-init="person={firstName:'yan',lastName:'cheng'}">
        <p>姓为 {{ person.lastName }}</p>
    </div>
    
    <!-- 使用 ng-bind 的相同实例 -->
    <div ng-app="" ng-init="person={firstName:'John',lastName:'Doe'}">  
        <p>姓为 <span ng-bind="person.lastName"></span></p>  
    </div>

     

      AngularJS 数组

    <div ng-app="" ng-init="points=[1,2,3,4]">
        <p>第三个值为 {{ points[2] }}</p>
    </div>
    
    <!-- 使用 ng-bind 的相同实例 -->
    <div ng-app="" ng-init="points=[1,15,19,2,40]">  
        <p>第三个值为 <span ng-bind="points[2]"></span></p>  
    </div>
  • 相关阅读:
    [ABC200E] Patisserie ABC 2
    [CF1521E] Nastia and a Beautiful Matrix
    [CF1498D] Bananas in a Microwave
    [CF1515B] Phoenix and Puzzle
    [CF1519C] Berland Regional
    [CF1519B] The Cake Is a Lie
    [ZONe Energy Programming Contest C] MAD TEAM
    [洛谷P7480] Reboot from Blue
    [CF1508A] Binary Literature
    1371. 货币系统
  • 原文地址:https://www.cnblogs.com/vicii/p/6513654.html
Copyright © 2020-2023  润新知