Hello.
I have no idea why my ng-repeat do not update after I insert a new record
to my database without refreshing the page.
my template file:
<div ng-controller="userController">
<button ng-click="open()">הוספת איש חדש</button>
<div class="row">
<div ng-repeat="user in users">
<div class="span6">
<div class="col-lg-5">
<div class="media">
<a class="pull-left" href="#">
<img class="media-object dp img-circle" src=
"http://www.huffmancode.com/img/hardik.jpg" style="width: 100px;height:100px
;">
</a>
<div class="media-body">
<h4 class="media-heading">{{user.username}} <small> מדינה
</small></h4>
<h5>על עצמי</a></h5>
<hr style="margin:8px auto">
<span class="label label-default">כישורים</span>
</div>
</div>
</div>
</div>
</div>
<script type="text/ng-template" id="firstDialog">
<form id="newTaskForm" class="add-user" ng-controller="userController">
<div class="form-actions">
<div class="input-group">
<input type="text" class="form-control" name="comment" ng-model="taskInput"
placeholder="Add New Task">
<div class="input-group-btn">
<button class="btn btn-default" type="submit" ng-click="addUser(taskInput)"
><i class="glyphicon glyphicon-plus"></i> Add New Task</button>
</div>
</div>
</div>
</form>
</script>
</div>
</div>
My app.js file:
//Define an angular module for our app
var app = angular.module('myApp', ['ngDialog']);
app.controller('userController', function($scope, $http, ngDialog) {
getUser(); // Load all available tasks
function getUser(){
$http.post("ajax/getUser.php").success(function(data){
$scope.users = data;
});
};
$scope.addUser = function (username) {
$http.post("ajax/addUser.php?user="+username).success(function(data){
getUser();
$scope.taskInput = "";
ngDialog.close();
});
};
$scope.open = function () {
ngDialog.open({
template: 'firstDialog'
});
};
});
Thanks in advance!
--
You received this message because you are subscribed to the Google Groups
"AngularJS" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/angular.
For more options, visit https://groups.google.com/d/optout.