$ routingprovider does not work yeoman angular

1

The routing is not working for me when generating the project in Yeoman, I do not understand the reason.

When I click on any item in the menu, it does not redirect me to that part:

home: link .  about: link .  loguin: link .

index.html

      <div class="collapse navbar-collapse" id="js-navbar-collapse">

        <ul class="nav navbar-nav">
          <li class="active"><a href="#/">Home</a></li>
          <li><a ng-href="#/about">About</a></li>
          <li><a ng-href="#/login">Iniciar sesiòn</a></li>
        </ul>
      </div>

controllers:

loginCtrl

    'use strict';

    angular.module('apiFrontApp').controller( 'LoginCtrl' , function(){

     var vm = this;

     vm.loginForm = {

        email : '',
        password : ''
     };

   });  

app.js

    'use strict';

    /**
    * @ngdoc overview
    * @name apiFrontApp
    * @description
    * # apiFrontApp
    *
    * Main module of the application.
    */
    var app = angular
    .module('apiFrontApp', [
     'ngAnimate',
     'ngAria',
     'ngCookies',
     'ngMessages',
     'ngResource',
     'ngRoute',
     'ngSanitize',
     'ngTouch',
     'satellizer'
   ]);
     app.config(function ($routeProvider, $authProvider , $locationProvider){

      $locationProvider.html5Mode(true);
      $authProvider.loginUrl = 
      'http://localhost:8888/api-cat/api-dev/public/auth_login';
      $routeProvider
        .when('/', {
          templateUrl: 'views/main.html',
          controller: 'MainCtrl',
          controllerAs: 'main'
        })
        .when('/about', {
         templateUrl: 'views/about.html',
         controller: 'AboutCtrl',
         controllerAs: 'about'
       })
       .when( '/login' ,{
         templateUrl: 'views/login.html',
         controller: 'LoginCtrl',
         controllerAs: 'login'

       })
       .otherwise({
         redirectTo: '/'
       });

    });
    
asked by Corovino 29.01.2017 в 04:49
source

2 answers

0

In the version of angular 1.6. * a prefix was added to the URL, to resolve that error in the app.js file add the following line as follows:

...     
  'ngTouch',
         'satellizer'
       ]);
 app.config(function ($routeProvider, $authProvider , $locationProvider){

    $locationProvider.hashPrefix(''); //Esta linea de codigo

    $locationProvider.html5Mode(true);
          $authProvider.loginUrl = 
          'http://localhost:8888/api-cat/api-dev/public/auth_login';
          $routeProvider
            .when('/', {
              templateUrl: 'views/main.html',
              controller: 'MainCtrl',
              controllerAs: 'main'
            })
...
    
answered by 31.01.2017 в 20:51
0

in index.html change:

<li class="active"><a href="#/">Home</a></li>

by:

<li class="active"><a href="#">Home</a></li>

the same in the title:

<a class="navbar-brand" href="#">"Title"</a>

all because "Home" is the active class and generates the problem on the other pages.

Greetings from Chile!

    
answered by 02.10.2017 в 17:14