1

I want to serve a page that already has data populated from PHP, and use AngularJS to edit and update this data, but initially I don't want to load the data into AngularJS.

Is there a way to disable data binding on load so that AngularJS doesn't replace the data that's already there, but enable it later when I edit some data and want to update the element?

2
  • That's very un-Angular-y, the purpose of Angular is data-binding. Any reason you're looking to do it this way? A better way would be to load the page, fire back a service and request your data, then display said data. Commented Oct 4, 2013 at 14:20
  • The reason is that this page is going to be cached, and I want to avoid any request to the API on page load, so the cached page needs to have all the data already. Commented Oct 4, 2013 at 14:57

2 Answers 2

1

May be you should to populate the template only using angularjs. Why would you want duplicate work by doing serverside templating and client side templating? I agree with @tymeJV. It is very un-Angular-y,

Or if you really want, you would want to have an init_function inside the angularjs controller that will be called only on edit and will load data when it does that. But I am not very convinced

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

1 Comment

I have an init function in place, but the problem is that AngularJS removes the data that's already in the HTML if there's no data loaded into the scope object.
0

You can use the ng-init attribute. This post describes how you can use it.

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.