day66—angularJS学习笔记-表达式

转行学开发,代码100天——2018-05-21

angular的变量数据初始化:

ng-init="quantity=1;cost=30;student={firstName:'李',lastName:'刚',rollno:101};marks=[82,91,78,77,64]"

数据调用:{{参数}}

<!DOCTYPE html>
<html>
<head>
    <title>angularJS 表达式</title>
    <script type="text/javascript" src="js/angular.min.js"></script>
    <script type="text/javascript">
        angular.module("myApp",[]).controller('control1',function($scope) { 
        });
    </script>
</head>
<body ng-app="myApp" ng-init="quantity=1;cost=30;student={firstName:'李',lastName:'刚',rollno:101};marks=[82,91,78,77,64]">
<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>
</body>
</html>

 

原文地址:https://www.cnblogs.com/allencxw/p/9074096.html