Explanation of Anguilar JS . When Controller is in the same page . Which i would never recommend .But Stilll you never know what is the customer Desires.
<!DOCTYPE html>
<html ng-app="" xmlns="http://www.w3.org/1999/xhtml">
<head>
<title></title>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.0/angular.min.js"></script>
</head>
<body ng-controller="frstCntrl">
<div>
<input type="button" value="Click Me" ng-click="ShowAlert()" />
<br />
<input type="button" value="HitMe" ng-click="Clicked()" />
<div ng-repeat="class in data.jsondatas">
{{class.City}}+{{class.Country}}
</div>
</div>
<script type="text/javascript">
function frstCntrl($scope, $http) {
$scope.data = {};
var jsondata = {};
$scope.ShowAlert = function () {
alert('Clicked');
};
$scope.Clicked = function () {
$http({
url: "http://www.w3schools.com/website/Customers_JSON.php",
method: "GET",
}).success(function (data) { console.log(data); $scope.data.jsondatas = data; console.log($scope.data.jsondatas); }).error(function (data) { console.log(data); });
};
}
</script>
</body>
</html>
<!DOCTYPE html>
<html ng-app="" xmlns="http://www.w3.org/1999/xhtml">
<head>
<title></title>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.0/angular.min.js"></script>
</head>
<body ng-controller="frstCntrl">
<div>
<input type="button" value="Click Me" ng-click="ShowAlert()" />
<br />
<input type="button" value="HitMe" ng-click="Clicked()" />
<div ng-repeat="class in data.jsondatas">
{{class.City}}+{{class.Country}}
</div>
</div>
<script type="text/javascript">
function frstCntrl($scope, $http) {
$scope.data = {};
var jsondata = {};
$scope.ShowAlert = function () {
alert('Clicked');
};
$scope.Clicked = function () {
$http({
url: "http://www.w3schools.com/website/Customers_JSON.php",
method: "GET",
}).success(function (data) { console.log(data); $scope.data.jsondatas = data; console.log($scope.data.jsondatas); }).error(function (data) { console.log(data); });
};
}
</script>
</body>
</html>
ConversionConversion EmoticonEmoticon