首页 > 代码库 > Angular_(数组的操作)
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="http://www.mamicode.com/js/angular-1.3.0.js"></script>
<script src="http://www.mamicode.com/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;
};
});
Angular_(数组的操作)
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。