How to update form using Angularjs and codeigniter?

As you all know Angularjs is getting popularity day by day, because of its data binding and dependency injection to reduce code, otherwise we need to write lot of code, client side framework, easy to integrate with any language which makes in top position. In previous discussion we had worked on ng-route model.
Now we will discuss how to update form using Angularjs and codeigniter, before going to concept you all need to know about Factory provider, which will adds below abilities.

  • We can use other services(which have dependencies).
  • We can initialize the service.
  • Delayed and Lazy initialization can be done using Factor recipe.

Now I will use factory recipe in our update form functionality, let’s create app.js file

Don’t be panic seeing the above angular code, which is easy to understand, let’s check the code now.
Here we create update controller in our app.js file, I had used dependency injection concept by calling factory service in update Controller.
In the factory recipe I used two functions to get the data which need to be updated and used post method to update the record, now I called these two functions in update controller.
Now let’s create form_edit.html in angular_pages folder as we discussed in previous article.

READ  Integrate CKeditor with codeigniter

Now look at codeigniter controller functions below.

Now let’s check model function how to update a record using below code.

[wp-like-lock]

[/wp-like-lock]

READ  How to fetch form data using Angularjs and display in codeigniter view?

Now we are at last step, while clicking the edit link we need to pass user_id to the angular controller, I am adding the single line of code, which needs to be placed in users_list.html and also update route config as below.

This file is already created in previous article, Please go through the complete article.

Thanks for reading this article ,for any queries please use comment section. Subscribe to eknowledgetree for new and latest classes.

Leave a Reply