angular杂集

<!DOCTYPE html>
<html>

<head>
<meta charset="UTF-8">
<title></title>
</head>

<body>
<div class="container" ng-app="myapp" ng-controller="ctrl">


<input type="text" name="" id="" value="" ng-model="txt"/>
<p>input值:{{txt}}</p>


<input type="num" name="" id="" value="" ng-model="first" ng-init="first=2"/>
<input type="num" name="" id="" value="" ng-model="second"ng-init="second=2"/>
<p>运算{{first*second}}</p>


<p ng-init="points=[1,15,19,2,40]"></p>
<p>第三个值为 {{ points[2] }}</p>


<h3>{{hname}}</h3>

<br />
<button>获取值</button>


<p ng-repeat="x in httptext1 |orderBy:'Country'">
<!--过滤和循环-->

{{x.Name+x.Url+x.Url}}
</p>

 

options
<select ng-init="selectedName = snames[0]" ng-model="selectedName" ng-options="x for x in snames"></select>

repeat

<table>
<tr>
<th>index</th>
<th>name</th>
<th>url</th>
<th>country</th>
</tr>
<tr ng-repeat="x in httptext" style="{{$even?'background-color: #f1f1f1':'background-color:#ccc'}}">
<td>{{ $index + 1 }}</td>
<td>{{x.Name}}</td>
<td>{{x.Url}}</td>
<td>{{x.Url}}</td>
</tr>
</table>

switch
选择一个选项:
<input type="radio" ng-model="myVar1" value="dogs">Dogs
<input type="radio" ng-model="myVar1" value="tuts">Tutorials
<input type="radio" ng-model="myVar1" value="cars">Cars


<div ng-switch="myVar1">
<div ng-switch-when="dogs">
<h1>Dogs</h1>
<p>Welcome to a world of dogs.</p>
</div>
<div ng-switch-when="tuts">
<h1>Tutorials</h1>
<p>Learn from examples.</p>
</div>
<div ng-switch-when="cars">
<h1>Cars</h1>
<p>Read about cars.</p>
</div>
</div>
</div>
</body>

</html>
<script src="http://cdn.static.runoob.com/libs/angular.js/1.4.6/angular.min.js"></script>
<script src="js/jquery-2.1.0.js" type="text/javascript" charset="utf-8"></script>
<script type="text/javascript">
var app = angular.module("myapp", []);
app.controller("ctrl", function($scope, $http) {
$scope.hname = "我是h3";
$scope.snames = ["Google", "Runoob", "Taobao"];
$http.get('angu.json').then(function(response) {
$scope.httptext = response.data.sites;
}, function() {
alert("连接错误")
});

$("button").eq(0).click(function() {
$http({
method: 'GET',
url: 'angu.json'
}).then(function successCallback(response) {
// 请求成功执行代码
$scope.httptext1 = response.data.sites;
}, function errorCallback(response) {
// 请求失败执行代码
});
});
})
</script>

转载于:https://www.cnblogs.com/SunSong/p/7028161.html

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值