AngularJS之表达式

来源:互联网 发布:ug nx软件 编辑:程序博客网 时间:2024/06/06 20:16

1、问题背景

     表达式分为:

(1)直接计算的加减乘除

(2)利用变量实现的加减乘除

(3)字符串表达式

(4)对象表达式

(5)数组表达式


2、实现源码

<!DOCTYPE html><html ng-app><head><meta charset="UTF-8"><title>AngularJS之表达式</title><script src="http://apps.bdimg.com/libs/angular.js/1.4.6/angular.min.js"></script><script></script></head><body><div><input type="text" ng-init="count=20;price=30"/><br><br><input type="text" ng-init="name='zhangsan';age=30"/><br><br><input type="text" ng-init="student={name:'张思',sex:'女'}"/><br><br><input type="text" ng-init="score=[78,89,90,96]"/><br><br>总数:{{5+2}}<br><br>总共:{{count*price}}<br><br>人员:{{"姓名:"+name+"年龄:"+age}}<br><br>姓名:<span ng-bind="student.name"></span><br><br>性别:<span ng-bind="student.sex"></span><br><br>分数:<span ng-bind="score[2]"></span><br><br></div></body></html>

3、实现结果


0 0
原创粉丝点击