Maby this will help you.
suggestion 1 :
$http.post("ajax/addUser.php?user="+username).success(function(data){
$scope.users.push(data);
})
suggestion 2:
Try to $apply() your scope after update database.
In my code I have:
<li ng-repeat="child in children" class="group-{[{ child.id }]}>
<i ng-if="child.childrenCount > 0" class="fa fa-plus"></i>
<a href="">
{[{ child.name }]}
</a>
</li>
scope.changeParent = function(current_group_id, new_parent_id) {
var group = GroupFactory.changeParent(meta, $.param(data));
group.then(function(results) {
angular.forEach(scope.groups, function(value, key) {
if (value.id === new_parent_id) {
angular.element('li.group-'+new_parent_id).scope().child.childrenCount =
1;
setTimeout(function() {
angular.element('li.group-'+new_parent_id).scope().$apply();
});
}
})
}
So I have X <li> elements in my ng-repeat, it its a tree like:
- gruop A
- - group B
- - group C
- group D
- - group E
- - - group F
- - group G
- group H
- group I
I can move one <li> to be as a children of another:
- group H
- group I
---move group --->>
- group H
- - group I
After $http success i need to change my icon fa-plus to show that group H
has now a children. I have to update group H scope to set childrenCount = 1
and than update his scope()
angular.element('li.group-'+new_parent_id).scope().child.childrenCount = 1;
setTimeout(function() {
angular.element('li.group-'+new_parent_id).scope().$apply();
});
so now the icon is shown without page refresh
--
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.