<ion-view title="news">
<ion-content class="has-header">
<div ng-repeat="x in names">
Id: {{x.Id }}<br>
Author: {{ x.Author }}<br>
Title: {{ x.Title }}<br>
<hr>
</div>
</ion-content>
</ion-view>angular.module('taufan.ionizer.app.controllers', [])
//news controller
.controller('myctrl', function($scope, $http, IonizerService) {
$http.get("http://localhost//show_news_app.php")
.then(function (response) {$scope.names = response.data.records;});
})angular.module('taufan.ionizer.app', ['ionic', 'taufan.ionizer.app.controllers', 'taufan.ionizer.app.services', 'taufan.ionizer.app.directives', 'taufan.ionizer.app.filters'])
.state('app.news', {
url: "/news",
views: {
'menuContent': {
templateUrl: "templates/news.html",
controller: "myctrl"
}
}
})
.state('app.newsdetail', {
url: "/news/:newsId",
views: {
'menuContent': {
templateUrl: "templates/newsDetail.html",
controller: 'NewsDetailCtrl'
}
}
})<?php
header("Access-Control-Allow-Origin: *");
header("Content-Type: application/json; charset=UTF-8");
$conn = new mysqli("localhost", "root", "password", "test");
$result = $conn->query("SELECT Id, Author, Title, Text FROM post");
$outp = "";
while($rs = $result->fetch_array(MYSQLI_ASSOC)) {
if ($outp != "") {$outp .= ",";}
$outp .= '{"Id":"' .$rs["Id"] . '",';
$outp .= '"Author":"' . $rs["Author"] . '",';
$outp .= '"Title":"' . $rs["Title"] . '",';
$outp .= '"Text":"'. $rs["Text"] . '"}';
}
$outp ='{"records":['.$outp.']}';
$conn->close();
echo($outp);
?>