本文主要讲解AngularJS表达式,这里整理了相关资料和提供示例代码以及实现效果图,有需要的小伙伴可以参考下
表达式用于应用程序数据绑定到HTML。表达式都写在双括号就像{{表达式}}。表达式中的行为跟ng-bind指令方式相同。 AngularJS应用表达式是纯javascript表达式,来源gao@daima#com搞(%代@#码网并输出它们被使用的数据在那里。
使用数字
Expense on Books : {{cost * quantity}} Rs
使用字符串
Hello {{student.firstname + ” ” + student.lastname}}!
使用对象
Roll No: {{student.rollno}}
使用数组
Marks(Math): {{marks[3]}}
例子
下面的例子将展示上述所有表达式。
testAngularJS.html 文件代码如下:
<title>AngularJS Expressions</title> <h1>Sample Application</h1><div> <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>
输出
在Web浏览器打开textAngularJS.html。看到结果如下:
以上就是对AngularJS 表达式的资料整理,后续继续补充相关资料,谢谢大家对本站的支持!
以上就是AngularJS表达式讲解及示例代码的详细内容,更多请关注gaodaima搞代码网其它相关文章!