-
Notifications
You must be signed in to change notification settings - Fork 0
/
t1.html
66 lines (57 loc) · 1.52 KB
/
t1.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
<!DOCTYPE html>
<html>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.6.9/angular.min.js"></script>
<body>
<div ng-app="myApp" >
<div ng-controller="personCtrl">
First Name: <input type="text" ng-model="firstName"><br>
Last Name: <input type="text" ng-model="lastName"><br>
<br>
Full Name: {{fullName()}}
</div>
<div ng-controller="namesCtrl">
<ul>
<li ng-repeat="x in names">
{{ x.name + ', ' + x.country }}
</li>
</ul>
<hr>
<select ng-change="change_select(country)" ng-model="country">
<option ng-repeat="x in names" value="{{x.country}}">{{x.name}}</option>
</select>
Your choice: {{fullinfo}}
<hr>
<input type="button" value="hahaha" ng-click="clickme()">
</div>
</div>
<script>
var app = angular.module('myApp', []);
app.controller('personCtrl', function($scope) {
$scope.firstName = "John";
$scope.lastName = "Doe";
$scope.fullName = function() {
return $scope.firstName + " " + $scope.lastName;
};
});
app.controller('namesCtrl', function($scope) {
$scope.names = [
{name:'Jani',country:'Norway'},
{name:'Hege',country:'Sweden'},
{name:'Kai',country:'Denmark'}
];
$scope.fullinfo='hahahah';
$scope.change_select=function(selected){
var country=$scope.country;
var name=$.grep($scope.names, function (x){
return x.country == country;
})[0].name;
$scope.fullinfo=name+' - '+country;
};
$scope.clickme=function(){
alert('hihihii');
}
});
</script>
</body>
</html>