源码网商城,靠谱的源码在线交易网站 我的订单 购物车 帮助

源码网商城

AngularJS表达式讲解及示例代码

  • 时间:2021-06-20 12:46 编辑: 来源: 阅读:
  • 扫一扫,手机访问
摘要:AngularJS表达式讲解及示例代码
表达式用于应用程序数据绑定到HTML。表达式都写在双括号就像{{表达式}}。表达式中的行为跟ng-bind指令方式相同。 AngularJS应用表达式是纯javascript表达式,并输出它们被使用的数据在那里。 [b]使用数字[/b] <p>Expense on Books : {{cost * quantity}} Rs</p> [b]使用字符串[/b] <p>Hello {{student.firstname + " " + student.lastname}}!</p> [b]使用对象[/b] <p>Roll No: {{student.rollno}}</p> [b]使用数组[/b] <p>Marks(Math): {{marks[3]}}</p> [b]例子[/b] 下面的例子将展示上述所有表达式。 testAngularJS.html 文件代码如下:
<html>
<title>AngularJS Expressions</title>
<body>
<h1>Sample Application</h1>
<div ng-app="" ng-init="quantity=1;cost=30; student={firstname:'Mahesh',lastname:'Parashar',rollno:101};marks=[80,90,75,73,60]">
  <p>Hello {{student.firstname + " " + student.lastname}}!</p>  
  <p>Expense on Books : {{cost * quantity}} Rs</p>
  <p>Roll No: {{student.rollno}}</p>
  <p>Marks(Math): {{marks[3]}}</p>
</div>
<script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.2.15/angular.min.js"></script>
</body>
</html>
[b]输出[/b] 在Web浏览器打开textAngularJS.html。看到结果如下: [img]http://files.jb51.net/file_images/article/201608/2016816160958252.png?2016716161013[/img] 以上就是对AngularJS 表达式的资料整理,后续继续补充相关资料,谢谢大家对本站的支持!
  • 全部评论(0)
联系客服
客服电话:
400-000-3129
微信版

扫一扫进微信版
返回顶部