Ad

Angular Js Remove # Tag With Using Codeigniter As Secondary Framework

i have used codeigniter us secondary framework in angularjs. What is the best way to remove # symbol from url and being and seo friendly website. Thanks in advance.

Ad

Answer

Use Location provider in angularjs and change the base href for css and js:

angular.module('scotchy', [])

.config(function($routeProvider, $locationProvider) {

    $routeProvider
        .when('/', {
            templateUrl : 'partials/home.html',
            controller : mainController
        })
        .when('/about', {
            templateUrl : 'partials/about.html',
            controller : mainController
        })
        .when('/contact', {
            templateUrl : 'partials/contact.html',
            controller : mainController
        });

    // use the HTML5 History API
    $locationProvider.html5Mode(true);
});

For more details about removing has tag

Add the following in application/config/routes.php to prevent 404 from CI

$route[''] = "";

$route['about'] = "";

$route['contact'] = "";

Happy coding :)

Ad
source: stackoverflow.com
Ad