Join the Stack Overflow Community
Stack Overflow is a community of 6.7 million programmers, just like you, helping each other.
Join them; it only takes a minute:
Sign up

I'm trying to use Angular with my Codeigniter project. The problem is that it doesn't load the proper template file through angular router.

In the root instead of showing templateUrl: 'index.php/welcome/home', it loads the index.php/welcome. It loads the index page inside the controller instead of the ones I have specified.

Below is my code:

JS

var app = angular.module('MyCtrl', ['ngRoute', "ui.bootstrap.modal"]);
app.config(function($routeProvider) {
    $routeProvider
    .when('/', {
        templateUrl: 'index.php/welcome/home',
        controller: 'mainController'
    })

    .when('/user', {
        templateUrl: 'index.php/user/account',
        controller: 'userController'
    })

});

app.controller('mainController', function($scope) {
    $scope.message = 'main con';
});

app.controller('userController', function($scope) {
    $scope.message = 'user con!';
});

Welcome controller in Codeigniter:

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

Can someone tell me why this is not working and what I have done wrong?

share|improve this question
    
When you request directly "index.php/welcome/home" does it load your template? – Ilya Luzyanin Jan 10 at 18:50
    
@IlyaLuzyanin Yep.. When i access the url directly it loads the template – LiveEn Jan 11 at 5:59

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.