Click here to Skip to main content
15,908,172 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
this is my index.html
HTML
<pre><!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" ng-app="myapp">
<head>
    <title></title>
    <script src="scripts/angular-route-min.js"></script>
    <script src="scripts/angular.min.js"></script>
    <script src="scripts/JavaScript1.js"></script>
</head>
<body>
    <a href="#home">Home</a>
    <table ng-view></table>
   
</body>
</html>


here is my script file
JavaScript
<pre>/// <reference path="angular.min.js" />
/// <reference path="angular-route-min.js" />
var app = angular.module("myapp", ["ngRoute"])
                 .config(function ($routeProvider) {
                     $routeProvider.when("/home", {
                         templateUrl: "Templates/home.html",
                         controller: "homectrl"
                     })
                 }).controller("homectrl", function ($scope) {
                     $scope.message = "home page";
                 });


below is the injected view

HTML
<pre><h1>{{message}}</h1>
<h2>hi</h2>


What I have tried:

tried various of changing syntax but no use
Posted
Updated 6-Jun-17 17:30pm

1 solution

refer this

<html xmlns="http://www.w3.org/1999/xhtml" ng-app="myapp">
<head>
    <title></title>
    <base href="/">
    <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.6.4/angular.min.js"></script>    
    <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.6.4/angular-route.js"></script>
    <script>
        var app = angular.module("myapp", ["ngRoute"])
                 .config(function ($routeProvider, $locationProvider) {
                     $routeProvider.when("/home", {
                         templateUrl: "Templates/home.html",
                         controller: "homectrl"
                     })
                     $locationProvider.html5Mode(true);  
                 }).controller("homectrl", function ($scope) {
                     $scope.message = "home page";
                 });
    </script>
</head>
<body>
    <a href="home">Home</a>     
    <table ng-view></table>

</body>
</html>
 
Share this answer
 
v2
Comments
Member 12677894 7-Jun-17 3:02am    
i just changed my angular js script files reference with CDN link, it works well, but when i reference the downloaded scripts, routing doesn't work
Karthik_Mahalingam 7-Jun-17 3:31am    
which version
Member 12677894 7-Jun-17 4:04am    
1.6.4
Karthik_Mahalingam 7-Jun-17 8:18am    
i have tested the same with local files it works good.
you might be missing something.

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