Click here to Skip to main content
15,896,063 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
i hav tried almost.. but ngroute is not working in app . pls tell me where is the wrong

What I have tried:

JavaScript
var app = angular.module("myApp", ['ngRoute']);

app.config(function($routeProvider) {
    $routeProvider
        .when('/home', {
            templateUrl: 'mypages/home.html',
            controller: 'homectrl'
        })
        .when('/login', {
            templateUrl: 'mypages/login.html',
            controller: 'loginctrl'
        })
        .when('/details', {
            templateUrl: 'mypages/details.html',
            controller: 'detailsctrl'
        })
        .otherwise({
            redirectTo: '/home'
        });
});

HTML
<!DOCTYPE html>
<html ng-app="myApp">
<head>
    <title></title>

    <script src="../Scripts/angular-route.min.js"></script>
    <script src="../Scripts/angular-route.js"></script>
    <script src="../Scripts/angular.min.js"></script>
    <script src="../myscripts/main.js"></script>
</head>
<body>
    <!--<div ng-controller="indexctrl">
        <p>{{test}}</p>
       <a href="#/home"> home</a>
        <a href="#/login"> login</a>
        <a href="#/details"> details</a>
    </div>
    <div>
        <ng-view></ng-view>
    </div>-->

</body>
</html>
Posted
Updated 20-Aug-16 1:48am
v3
Comments
Karthik_Mahalingam 20-Aug-16 4:02am    
paste the code in https://jsfiddle.net/ and share the link
Richard Deeming 20-Aug-16 7:50am    
The code needs to be HTML-encoded and wrapped in <pre>...</pre> tags. Unfortunately, the "what I have tried" box doesn't do that for you automatically.

I've updated your question to restore the HTML code block. However, you'd commented out the entire contents of the body. If that's your real code, then it probably explains why it's not working!
NarasinghRao 22-Aug-16 0:26am    
Yes. Richard.the code above in comment is correct.now tell me.why its not working?
Richard Deeming 22-Aug-16 7:48am    
Well if you've commented out the body, then there's nothing to display!

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900