-1

I am attempting to route my app with angular js routing however it is not working. When I click the link nothing happens. My html:

<!DOCTYPE html>
<html>
<script src="./music.js"></script>
<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.3.5/angular-route.min.js"></script>
<script src="./app.js"></script>
<script src="./route.js"></script>

<body ng-app="myApp" ng-controller="myCtrl">
<a href="#!/keyBoad">start</a>
<ng-view>

</ng-view>
<style>
button { width : 100px; height : 100px; } 
</style></body>

My js for routing:

app . config ( function ( $routeProvider ){ 
$routeProvider
. when ( '/keyBoard' , { 
templateUrl : 'keyBoard.html' }) . otherwise ({ 
redirectTo :'404.html' }); }); 

No errors are in my console and everything I've found about this issue doesn't help. What am I doing wrong?

user7951676
  • 377
  • 2
  • 10

1 Answers1

1
<a href="#!/keyBoad">start</a>

should be

<a href="#!/keyBoard">start</a>
  • I changed it to test the 404 page and forgot, why wasn't it redirecting with the otherwise method? – user7951676 Aug 09 '17 at 14:39
  • In future, do not provide a full answer to simple typo. Give the solution in the comments and additionally you should vote to close the question. The reason for this is that this question is of absolutely no use to anyone other than the OP, so is not much good on the site. – Jack Parkinson Aug 09 '17 at 14:40
  • That is because *redirectTo* redirects to a specific URL, not a file. So write a when for the "404.html" page with a route like "/404" or something and then "redirectTo: '/404'". –  Aug 09 '17 at 14:43
  • @Jack users aren't allowed to comment on questions until they have 50 rep I believe –  Aug 09 '17 at 14:45
  • Can't delete, sorry – user7951676 Aug 09 '17 at 14:48
  • And I thought the otherwise method would load the 404 if any links that weren't in the when methods was clicked – user7951676 Aug 09 '17 at 14:50
  • Yeah I think you're right. Try "templateUrl" instead of "redirectTo". –  Aug 09 '17 at 14:54