简体   繁体   English

角度路线似乎不会自动激活

[英]angular-route doesn't seem to activate automatically

I'm currently having an issue with the angular-route@1.5.8 module. 我目前在angular-route@1.5.8模块上遇到问题。

The router does not seem to activate on its own. 路由器似乎无法自行激活。 What I mean is that when I call the page ( http://localhost/index.html ), the requested template does not show up. 我的意思是,当我调用页面( http://localhost/index.html )时,请求的模板没有显示。 However, manually adding a hash (#) to the end of the url, activates the router and shows the correct template. 但是,手动在网址末尾添加井号(#),会激活路由器并显示正确的模板。

I build a test application with nearly the same router-configuration, and in that app the router works as expected. 我用几乎相同的路由器配置构建了一个测试应用程序,并且在该应用程序中,路由器能够按预期工作。

There are no errors logged in the console. 控制台中没有记录错误。

This is the config: 这是配置:

angular.module('app', ['ngRoute'])
       .config(function ($routeProvider) {
           $routeProvider
               .when('/', {
                   templateUrl: './app/html/default.html'
               })
               .when('/login', {
                   templateUrl: './app/html/login.html',
               })
               .otherwise({
                   redirectTo: '/'
               });
    });

The templates are basically a span-tag with some text to show what template is being displayed. 模板基本上是一个带有一些文本的span标签,以显示正在显示的模板。

Any help is appreaciated. 任何帮助表示赞赏。

Did you put ng-view directive on your index page? 您是否在索引页上放置了ng-view指令? You should share more of your the relevant routing codes, your html, your templates. 您应该共享更多相关的路由代码,html,模板。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM