javascript - angularjs ngRoute dont redirect -


<!doctype html> <html ng-app="routeapp"> <head>     <script src= "http://ajax.googleapis.com/ajax/libs/angularjs/1.3.14/angular.min.js"></script>     <script src="http://cdnjs.cloudflare.com/ajax/libs/angular.js/1.3.3/angular-route.min.js"></script>     <script src="controlles.js"></script>     <meta charset="utf-8">     <title>route mapping application</title> </head>  <body>     salut      <div ng-view></div>     <br>      <nav>         <a href="#/home">page d'accueil</a>         <a href="#/contact">page de contact</a>     </nav> </body> </html> 

and controllers:

'use strict'  /**  * déclaration de l'application routeapp  */ var routeapp = angular.module('routeapp', [     // dépendances du "module"     'ngroute' ]);  routeapp.config(['$routeprovider',      function($routeprovider) {         //systeme de routage          console.log('rederction');          $routeprovider.when('/home',{templateurl: 'views/home.html', controller: 'homectrl'})                       .when ('/contact/',{templateurl: 'views/contact.html', controller: 'contactctrl'})                       .otherwise({redirectto: '/home'});     } ]);  // contrôleur de la page d'accueil routeapp.controller('homectrl', ['$scope', function($scope) {         $scope.message = "bienvenue sur la page d'accueil";     } ]);  // contrôleur de la page de contact routeapp.controller('contactctrl', ['$scope', function($scope) {         $scope.message = "laissez-nous un message sur la page de contact !";     } ]); 

and home.html:

<!doctype html> <html> <head>     <script src= "http://ajax.googleapis.com/ajax/libs/angularjs/1.3.14/angular.min.js"></script>     <script src="controlles.js"></script>     <meta charset="utf-8">     <title>home </title> </head>  <body>     template home : {{message}}     {{2+2}}     <div ng-view></div> </body> </html> 

when test in internet explorer, access denied error, , in google chrome receive following

error: failed execute 'send' on 'xmlhttprequest': failed load 'file:///c:/users/mehdi/phpstormprojects/mapping/views/home.html'.     @ error (native) 

you need load index.html web server instead of file directory.


Comments

Popular posts from this blog

python - pip install -U PySide error -

arrays - C++ error: a brace-enclosed initializer is not allowed here before ‘{’ token -

cytoscape.js - How to add nodes to Dagre layout with Cytoscape -