Angular(数组的操作)

html部分

..............................................

<!doctype html>
<html ng-app="myApp">
<head>
<meta charset="UTF-8">
<title>AngularJS Expressions</title>
<style>
a{color: blue; text-decoration: underline; cursor: pointer}
</style>

</head>
<body>
<div ng-controller="myController">
1.表达式与作用域交互<br>
{{speed}} {{vehicle}}<hr>

2.访问作用域中的变量:<br>
{{speed + ' ' + vehicle}}<hr>

3.调用作用域中的函数:<br>
{{lower(speed)}} {{upper('Jeep')}}<hr>

<a ng-click="setValues('Fast', newVehicle)">
Click to change to Fast {{newVehicle}}</a><hr>
<a ng-click="setValues(newSpeed, 'Rocket')">
Click to change to {{newSpeed}} Rocket</a><hr>
<a ng-click="vehicle='Car'">
Click to change the vehicle to a Car</a><hr>
<a ng-click="vehicle='Enhanced' + vehicle">
Click to Enhance Vehicle</a><hr>
</div>
<script src="js/angular-1.3.0.js"></script>
<script src="js/day2_text8.js"></script>
</body>
</html>
..................................
js部分

angular.module('myApp', [])
.controller('myController', function($scope) {
$scope.speed = 'Slow';
$scope.vehicle = 'Train';
$scope.newSpeed = 'Hypersonic';
$scope.newVehicle = 'Plane';
$scope.upper=function(aString){
return angular.uppercase(aString);
};
$scope.lower = function(aString){
return angular.lowercase(aString);
};
$scope.setValues = function(speed, vehicle){
$scope.speed = speed;
$scope.vehicle = vehicle;
};
});

转载于:https://www.cnblogs.com/YoogaChan/p/6920527.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值