3

While using Angularjs v0.9 and php to implement my membership system

In this following function, I will call an api to edit the data of the member, on success, the php function will return

{"success":"true"}

and the controller will return to a page that can view the member of the data.

if(response.success==="true") {
window.location="#/register_members";
$('.alert-error').hide();
$('.alert-success').html("Member is updated.");
$('.alert-success').fadeIn();
}

However, at #/register_members, the data still remains as the unchanged data. Is there anyway I can refresh the page partially in angularjs? I am using ng:view and $route.

I have tried using

window.location.reload(true);

but the success message will not be rendered as the whole page is renewed.

Does anyone have any idea?

2
  • One question: Why are u still using 0.9? I would rely on the location service of Angular which works fine for me in every case. Second thing, why do you use jQuery to update the dom within the controller? You can just use two-way binding and update the variable. Or did I got something wrong? Commented Oct 27, 2012 at 19:57
  • the php API function will update the database and will return a response. So i am working with the response. :) it was an old project with v0.9. just taking out to try other stuffs. Commented Oct 28, 2012 at 9:12

1 Answer 1

1

Found an interesting answer here to refresh a div in the page using Jquery

my page is "#/register_members" the div i want to update is "#registerlist" which is inside a div called "#browse-box".

so now my controller will be

window.location="#/register_members";
$("#browse-box").load("/#/register_members #registerlist")
$('.alert-error').hide();
$('.alert-success').html("Member is updated.");
$('.alert-success').fadeIn();

works like a charm. :)

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.