0

I want to build SPA web app with Angular.js, however it will use Codeigniter MVC on the server side.

I am confused because to follow the Codeigniter MVC rules all views should be under application/views folder and those should be accessible by calling an controller method which will return view. I read about angular angular.js structure and I think the solution described here is very good. However, following this structure all views excluding index should be in public html/app/module_name/ folder.

I am wondering where html views should go? To public HTML or to application/views folder and what is the difference, how it could affect my further app?

I hope that I described my problem well enough.

Thanks in advance.

3
  • You probably don't need codeigniter to deliver views .. just extra overhead vs serving html file directly. Backend is usually just used for api. Start by thinking of codeigniter and angular as 2 separate entities Commented Aug 12, 2015 at 16:05
  • what about the "security" is there a difference if all people even if they are not logged in will have access to all views which will be stored in public folder and they can see more structure of the app? Commented Aug 12, 2015 at 16:07
  • 1
    If you didn't want anyone looking at any html you could deliver them through framework, but is usually not that big a deal since data would be not delivered if not logged in Commented Aug 12, 2015 at 16:30

1 Answer 1

1

codeIgniter multi views load are not for SPA (Single page application), angularJS is for SPA, what you need to do is load a single PHP page from codeiginter and use partials with ng-include or directives.

public function index()
{
    $this->load->view('main');
}

main.php:

<div ng-include="pathToHTMlView.html"></div>
<script src="angular.js"></script>
Sign up to request clarification or add additional context in comments.

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.