<div ng-app="Demo"></div>
<div ng-app="Demo" ng-init="firstName='John'">
<p>我的名字是:{{ firstName }}</p>
</div>
<div ng-app="Demo" ng-init="firstName='John'">
<p>姓名:<input type="text" ng-model="firstName"></p>
<p>我的名字是:{{ firstName }}</p>
</div>
<div ng-app="Demo" ng-init="names=[
{name:'Jani',country:'Norway'},
{name:'Hege',country:'Sweden'},
{name:'Kai',country:'Denmark'}]">
<ul>
<li ng-repeat="x in names">
{{ x.name + ', ' + x.country }}
</li>
</ul>
</div>
<div ng-app="Demo">
<h1 ng-controller="DemoCtrl">{{name}}</h1>
<h1 ng-controller="DemoCtrl2">{{lastName}}</h1>
</div>
<script>
// $scope表示作用区域,指向当前controller
// 每个应用都有一个$rootScope,它可以作用在 ng-app 指令包含的所有 HTML 元素中。用 rootscope 定义的值,可以在各个 controller 中使用。
var app = angular.module('Demo', []);
app.controller('DemoCtrl', function($scope, $rootScope) {
$scope.name = "Volvo";
$rootScope.lastName = "Tom";
});
</script>
<div ng-app="Demo" ng-controller="personCtrl">
名: <input type="text" ng-model="firstName">
<br>
姓: <input type="text" ng-model="lastName">
<br>
姓名: {{fullName()}}
</div>
<script>
var app = angular.module('Demo', []);
app.controller('personCtrl', function($scope) {
$scope.firstName = "John";
$scope.lastName = "Doe";
$scope.fullName = function() {
return $scope.firstName + " " + $scope.lastName;
}
});
</script>
<div ng-app="Demo" ng-controller="DemoCtrl">
<select ng-model="selectedName" ng-options="x for x in names">
</select>
</div>
<script>
var app = angular.module('myApp', []);
app.controller('myCtrl', function($scope) {
$scope.names = ["Google", "W3Cschool", "Taobao"];
});
</script>
<div ng-app="" ng-init="mySwitch=true">
<button ng-disabled="mySwitch">点我!</button>
<input type="checkbox" ng-model="mySwitch"/>按钮
{{ mySwitch }}
</div>
<div ng-app=""> <p ng-show="true">我是可见的。</p> <p ng-show="false">我是不可见的。</p> </div>
<div ng-app="Demo" ng-controller="myController">
<button ng-click="count = count + 1">点我!</button>
<p>{{ count }}</p>
</div>
<div ng-app="Demo" ng-controller="DemoCtrl">
<p>姓名为 {{ lastName | uppercase }}</p>
</div>
<div ng-app="Demo" ng-controller="DemoCtrl">
<ul>
<li ng-repeat="x in names | orderBy:'country'">
{{ x.name + ', ' + x.country }}
</li>
</ul>
</div>
app.service('hexafy', function() {
this.myFunc = function (x) {
return x.toString(16);
}
});
var app = angular.module('Demo', []);
app.controller('customersCtrl', function($scope, $location) {
$scope.myUrl = $location.absUrl();
});
var app = angular.module('Demo', []);
app.controller('DemoCtrl', function($scope, $http) {
$http({
url:'data.json',
method:'GET',
params:{
'username':'tan'
}
}).success(function(data,header,config,status){
//响应成功
}).error(function(data,header,config,status){
//处理响应失败
});
});
机械节能产品生产企业官网模板...
大气智能家居家具装修装饰类企业通用网站模板...
礼品公司网站模板
宽屏简约大气婚纱摄影影楼模板...
蓝白WAP手机综合医院类整站源码(独立后台)...苏ICP备2024110244号-2 苏公网安备32050702011978号 增值电信业务经营许可证编号:苏B2-20251499 | Copyright 2018 - 2025 源码网商城 (www.ymwmall.com) 版权所有