Having just started learning AngularJS, I have followed tutorials on YouTube and read the documentation, but I am struggling to display data from an API using the $http.get() request.
Here is my JavaScript and HTML code:
var exampleApp= angular.module('app', ['ionic']);
exampleApp.controller('exampleController', function($scope, $http){
$scope.getData=function(){
$http.get("https://p3ddibjuc6.execute-api.us-west-2.amazonaws.com/prod/entries")
.success(function(data){
$scope.Date= data.Date;
$scope.message= data.message;
})
.error(function(data){
alert("error");
})
};
} );
!DOCTYPE html>
<html ng-app="app">
<head>
<meta charset="utf-8">
<meta name="viewport" content="initial-scale=1, maximum-scale=1, user-scalable=no, width=device-width">
<link href="https://code.ionicframework.com/1.0.0/css/ionic.min.css" rel="stylesheet">
<script src="https://code.ionicframework.com/1.0.0/js/ionic.bundle.js"></script>
</head>
<body ng-app="app">
<ion-pane>
<ion-header-bar class="bar-stable">
<h1 class="title">Awesome App</h1>
</ion-header-bar>
<ion-content class="padding" ng-controller="exampleController">
<button class="button button-assertive" ng-click="getData()">click</button>
<br>
MESSAGE: {{message}}
<br>
Date: {{Date}}
</ion-content>
</ion-pane>
</body>
</html>
enter code here