2

I want to create an application where backend is driven by CodeIgniter and frontend by AnuglarJS.

As of now, I have an idea that we can use Angular JS $http service to get data from Codeigniter. But I am confused how to treat views.

For example:

My default controller is 'Login'. I created a login.php file in controllers folder and render the view of login form in index method. Now if I go with only CodeIgniter flow, I will simply place the form action to the doLogin() method of login controller and form there I will redirect user to his dashboard.

How can we achieve this in AngularJS so that when a user fill the form and hit login button, the page does not get refreshed and the dashboard appears?

0

3 Answers 3

5

check this GitHub project CodeIgniter AngularJS App. Another interesting answer is: Combining Angularjs and CodeIgniter. I hope I have helped...

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

Comments

1

Try using this seed, https://github.com/rmcdaniel/angular-codeigniter-seed come with JWT auth (no dealing with cookies)

Comments

1

Or you can create 2 different project. Angularjs & Codeigniter backend. Make Codeigniter backend work as RESTFul Server.

Now you can put CI backend project folder inside Angular Project folder or you can separate them.

In case of separate project folder, if CI backend fail to handle get/post due to "Cross-Origin Request Blocked", you can allow it from php/.htaccess file.

2 folder structure are like below.(according to xampp folder)

Nested folder structure

xampp/htdocs/my_ng_project/ (Angular project)
xampp/htdocs/my_ng_project/backend/ (CI project)

Separate folder structure

xampp/htdocs/my_ng_project/ (Angular project)
xampp/htdocs/backend/ (CI project)

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.