1

Angular route is not working for me..

My JS:

'use strict';

// Declare app level module which depends on filters, and services
var chatApp = angular.module('myApp', ['ngRoute']);

// configure our routes
chatApp.config(function($routeProvider) {
    $routeProvider

        // route for the home page
        .when('/index', {
            templateUrl : 'index.html',
            controller  : 'mainCtrl'
        })

        // route for the about page
        .when('/chat', {
            templateUrl : 'views/chat.html',
            controller  : 'chatCtrl'
        })
        .otherwise({redirectTo: '/index'});
});

chatApp.controller('mainCtrl', function($scope) {
    // create a message to display in our view
    $scope.message = 'Everyone come and see how good I look!';
});

chatApp.controller('chatCtrl', function($scope) {
    // create a message to display in our view
    $scope.message = 'Everyone come and see how good I look!';
});

In Html:

<html ng-app="myApp">

Added my scripts also.

<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.4.6/angular.min.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.4.6/angular-resource.min.js">
</script>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.4.6/angular-route.min.js">
</script>
<script src="https://cdn.firebase.com/js/client/2.0.4/firebase.js"></script>
<script src="https://cdn.firebase.com/libs/angularfire/0.9.0/angularfire.min.js"></script>
<script src="scripts/app.js"></script>


URL : ...goaway-web/app/chat  Example what I am trying. 
goaway-web/app/index

While redirecting or directly entering the URL it is not working.. Please help!!

3
  • did you get any error on your console? Commented Sep 28, 2015 at 9:30
  • 3
    Do you have ng-view? Commented Sep 28, 2015 at 9:33
  • @ShamalPerera . I agree with you. :=1 Commented Sep 28, 2015 at 9:34

1 Answer 1

2

Try with #.

Sample : <a href="#/index">SOME_DETAIL</a>

And please check, do you have implement ng-view on your index.html

Sign up to request clarification or add additional context in comments.

1 Comment

Can we see your anchor tag href with code? and tell us your application correct path. (what you eamn by view)?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.