After I input data to my log page and navigate/route to the loglist page, it will not update what I recently inserted.I need to refresh manually to update what i recently inserted. I want it to update automatically when I navigate to loglist. How to do that in Angularjs?
Note: I have two route page, log and loglist.
*I used ajax in my forms. I don't want to include other things like css here so that it is easy for you to understand the codes.
html sample
<nav>
<ul>
<li><a>Walk-In</a>
<ul>
<li><a href="#/">Log</a></li>
<li><a href="#/loglist">Log List</a></li>
</ul>
</li>
</ul>
</nav>
<div id="content">
<div id="showcontent" ng-view>
</div>
</div>
log.php
<form id="member" method="post" action="../php/connect.php">
<fieldset style="width:400; border-width:6px;" align="center" >
<legend><h3>Member Log</h3><br><br></legend>
<p id="get_member"></p>
<input class="fname" type='text' name='firstname' id='firstname' placeholder="First Name" required/>
</br><input class="lname" type='text' name='lastname' id='lastname' placeholder="Last Name" required /></br>
</br><label for="male">Male </label><input type="radio" name="gender" id="male" required value="Male" />
<label for="female">Female </label><input type="radio" name="gender" id="female" value="Female" /><br />
<input type="hidden" name="date" id="date" value="">
<input type="hidden" name="time" id="time" value="">
<br><br><input type="submit" name="submit">
</fieldset>
</form>
loglist.php
<table id='table12' class='order-table table'>
<thead id='top'>
<tr id='tr'>
<th>ID No.</th>
<th>Firstname</th>
<th>Lastname</th>
<th>Gender</th>
<th>Time</th>
<th>Date</th>
<th>Type</th>
</tr>
</thead>
<tbody>
<?php
$servername = "localhost";
$username = "root";
$password = "";
$dbname = "rmsdb";
$query=mysql_connect("localhost","root","");
mysql_select_db("rmsdb",$query);
$query1=mysql_query("select id, firstname, lastname, gender, time, datestamp from walkin");
while($query2=mysql_fetch_array($query1))
{
echo "<tr> <td>".$query2['id']."</td>
<td>".$query2['firstname']."</td>
<td>".$query2['lastname']."</td>
<td>".$query2['gender']."</td>
<td>".$query2['time']."</td>
<td>".$query2['datestamp']."</td></tr>";
}
?>
</tbody>
</table>
angular route
var myApp = angular.module('myApp', ['ngRoute']);
myApp.config(function ($routeProvider){
$routeProvider
.when('/', {
templateUrl: 'pages/log.php',
controller: 'mainController'
})
.when('/loglist', {
templateUrl: 'pages/loglist.php',
controller: 'secondController',
})
});