0

I'm new to angular trying to implement routing in my angularjs app. My app does the followings

  1. user can login via facebook
  2. then he/she can select a link to navigate

Following is my main angularjs file (with route and facebook connect, facebook connect is working :)), My problem is , routing doesnt work..

#app.js
var app = angular.module('myApp', ['facebook', 'ngRoute'])

    .config([
        'FacebookProvider',
        function(FacebookProvider) {
            var myAppId = '<FB app ID>';
            FacebookProvider.init(myAppId);

        }

    ],
     function($routeProvider) {
        $routeProvider
            // route for the home page
            .when('/add', {
                templateUrl : '../pages/add_form.html',
                controller  : 'addCtrl'
            })

            .when('/', {
                templateUrl : 'pages/home.html',
                controller  : 'mainController'
            });
      }  
    )

and when I add a debug pointer to line .when('/add', {control flow is not coming to that line at all.

Following is my href

<li><a href="#add">Add & Edit Recipes</a></li>

I'm following this tutorial for routing , any help would be greatly appreciated

** UPDATE **

my html

<!DOCTYPE html>
<html class="gt-ie8 gt-ie9 not-ie" data-ng-app="myApp">
  <head>
    //stuff
    <body class="theme-default no-main-menu main-navbar-fixed" data-ng-controller="MainController">

      <script>var init = [];</script>
      <div id="main-wrapper">
        // some html
        <ul class="nav navbar-nav">
      <li class="dropdown">
      <a href="#" class="dropdown-toggle" data-toggle="dropdown">Home&nbsp;&nbsp;<i class="navbar-icon fa fa-angle-down"></i></a>
      <ul class="dropdown-menu" data-ng-show="logged">
        <li><a href="#/add">Add & Edit Recipes</a></li>
        <li><a href="#">Unpublished</a></li>
        <li><a href="#">Published</a></li>
        <li class="divider"></li>
        <li><a href="#">Page 3</a></li>
      </ul>
      </li>
      <li><a href="#">Recipe</a></li>
    </ul>

        <div id="content-wrapper">
          <div ng-view>
            <%= yield %>
          </div>
        </div>
        <div id="main-menu-bg"></div>
      </div> 

    </body>
  </html>
sameera207
  • 16,547
  • 19
  • 87
  • 152

0 Answers0