Here is my html:-
<div ng-app="myApp">
<!-- this controller will be in different page -->
<table ng-controller="customersCtrl">
<tr ng-repeat="x in names">
<td><a ng-href="#/edit/{{x.id}}">{{ x.name }}</a></td>
<td>{{ x.description }}</td>
</tr>
</table>
<!-- this controller will be in different page -->
<div id="login" ng-controller='sign_up'>
<input type="text" size="40" ng-model="name"><br>
<input type="text" size="40" ng-model="description"><br>
<button ng-click="check_credentials()">Login</button><br>
<span id="message"></span>
</div>
</div>
Question:- I have two different controller, How can I automatically update my customerCtrl as soon as sign_up controller update?
here is my javascript code:-
var app = angular.module('myApp', [])
.controller('customersCtrl', function($scope, $http) {
$http.get("exp.php").success(function(response) {
$scope.names = response;
})
})
.controller('sign_up', function ($scope, $http) {
$scope.check_credentials = function () {
var request = $http({
method: "post",
url: window.location.href + "save.php",
data: {
name: $scope.name,
description: $scope.description
},
headers: { 'Content-Type': 'application/x-www-form-urlencoded' }
});
request.success(function (data) {
document.getElementById("message").textContent = "You have login successfully with name " + data;
});
}
})