angularjs 1.6.0 (latest now) routes not working

前端 未结 5 592
北恋
北恋 2020-11-22 03:57

I was expecting to see this question on Stackoverflow but didn\'t. Apparently I\'m the only one having this problem that seems to me to be very common.

I have a basi

5条回答
  •  梦毁少年i
    2020-11-22 04:21

    I couldn't get routing to work in 1.6.4 so I decided to use angular 1.5.11 and routing works fine although I needed to define all my routings in when(..) functions with trailing "/"

    If sticking to an older version of angular is an option for you then consider it since it may save your nerves...

    var app = angular.module("myApp", ["ngRoute"]);
    
    app.config(function($routeProvider) {
    $routeProvider
    .when("/layoutandviewbox", {
        templateUrl : "views/layout-and-viewbox.html"
    })
    .when("/basicshapes", {
        templateUrl : "views/basic-shapes.html"
    })
    .when("/advancedshapes", {
        templateUrl : "views/advanced-shapes.html"
    })
    .when("/groups", {
        templateUrl : "views/groups.html"
    })
    .when("/transformations", {
        templateUrl : "views/transformations.html"
    })
    .when("/effects", {
        templateUrl : "views/effects.html"
    })
    .when("/", {
        templateUrl : "views/basic-shapes.html"
    });
    });
    

提交回复
热议问题