93 lines
1.7 KiB
Plaintext
93 lines
1.7 KiB
Plaintext
<!DOCTYPE html>
|
|
<html ng-app="Temp">
|
|
<head>
|
|
<title>Temp</title>
|
|
<style>
|
|
a[ ng-click ] {
|
|
color: #ff00cc;
|
|
cursor: pointer;
|
|
text-decoration: underline;
|
|
}
|
|
</style>
|
|
<script type="text/javascript" src="lib/jquery.js"></script>
|
|
<script type="text/javascript" src="lib/angular.js"></script>
|
|
</head>
|
|
|
|
<body ng-controller="TempController">
|
|
<ul>
|
|
<li ng-repeat="entry in tempData">
|
|
{{ entry }}
|
|
</li>
|
|
</ul>
|
|
|
|
<script type="text/javascript">
|
|
var app = angular.module( "Temp", []);
|
|
app.controller(
|
|
"TempController",
|
|
function( $scope, tempService) {
|
|
|
|
$scope.tempData = [];
|
|
|
|
loadRemoteData();
|
|
|
|
|
|
|
|
function applyRemoteData(newData)
|
|
{
|
|
$scope.tempData = newData;
|
|
}
|
|
|
|
|
|
function loadRemoteData() {
|
|
tempService.getTemp()
|
|
.then(
|
|
function(tempData) {
|
|
applyRemoteData(tempData);
|
|
}
|
|
)
|
|
}
|
|
}
|
|
);
|
|
|
|
|
|
app.service(
|
|
"tempService",
|
|
function($http, $q) {
|
|
return({getTemp:getTemp});
|
|
|
|
function getTemp() {
|
|
var request = $http({
|
|
method: "get",
|
|
url:"/temp/all",
|
|
params: {
|
|
/* action:"get"*/
|
|
}
|
|
});
|
|
return (request.then(handleSuccess, handleError));
|
|
}
|
|
|
|
|
|
|
|
function handleError(response) {
|
|
if ( !angular.isObject(response.data) || !response.data.message) {
|
|
return( $q.reject("An unknown error occured"));
|
|
}
|
|
|
|
return($q.reject(response.data.message));
|
|
}
|
|
|
|
function handleSuccess(response)
|
|
{
|
|
return(response.data);
|
|
}
|
|
|
|
}
|
|
);
|
|
</script>
|
|
|
|
</body>
|
|
|
|
|
|
|
|
|
|
</html> |