user7576099
user7576099

Reputation:

Yeoman AngularJS generator issue with any route

I am really new with development. I am learning AngularJS.

I am having an issue with yo angular. It's generating the app, grunt serve is running locally. But when i click the about button it does not go to about page

Here is some code (these are generated by angular generator).

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="#/">Contact</a></li>
        </ul>
      </div>
    </div>
  </div>
</div>

app.js ( from scripts folder )

'use strict';

angular
  .module('coolAppApp', [
    'ngAnimate',
    'ngCookies',
    'ngResource',
'ngRoute',
'ngSanitize',
'ngTouch'
])
  .config(function ($routeProvider) {
$routeProvider
  .when('/', {
    templateUrl: 'views/main.html',
    controller: 'MainCtrl',
    controllerAs: 'main'
  })
  .when('/about', {
    templateUrl: 'views/about.html',
    controller: 'AboutCtrl',
    controllerAs: 'about'
  })
  .otherwise({
    redirectTo: '/'
  });
  });

Upvotes: 2

Views: 48

Answers (1)

user7576099
user7576099

Reputation:

Found the solution

it works with putting ! before /

which means <li><a ng-href="#!/about">About</a></li>

Upvotes: 1

Related Questions