Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/meteor/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
使用angular meteor直接在地址栏上键入时,路由不起作用_Meteor_Angular Ui Router_Angular Meteor - Fatal编程技术网

使用angular meteor直接在地址栏上键入时,路由不起作用

使用angular meteor直接在地址栏上键入时,路由不起作用,meteor,angular-ui-router,angular-meteor,Meteor,Angular Ui Router,Angular Meteor,我在研究角流星。我定义了如下路线: angular.module('myapp').config(function($stateProvider, $urlRouterProvider, $locationProvider) { $locationProvider.html5Mode(true); $stateProvider .state('homepage', { url: '/homepage',

我在研究角流星。我定义了如下路线:

    angular.module('myapp').config(function($stateProvider, $urlRouterProvider, $locationProvider) {

        $locationProvider.html5Mode(true);
        $stateProvider
        .state('homepage', {

           url: '/homepage',
           template: '<mycomponent></mycomponent>'
        })

        .state('anotherpage', {

          url: '/other-route',
          template: '<othercomponent></othercomponent>'
        });
        $urlRouterProvider.otherwise('/homepage');
    });
angular.module('myapp').config(函数($stateProvider、$urlRouterProvider、$locationProvider){
$locationProvider.html5Mode(true);
$stateProvider
.state('主页'{
url:“/主页”,
模板:“”
})
.state('另一页'{
url:“/其他路由”,
模板:“”
});
$urlRouterProvider。否则('/homepage');
});

一切正常,直到我直接在地址栏中键入指向/other route的url。浏览器只是返回到/主页。提示?谢谢。

如果您使用ASP.Net,则需要使用配置global.asax文件

private const string ROOT_DOCUMENT=“/Index.html”;
受保护的无效应用程序\u BeginRequest(对象发送方,事件参数e)
{
var path=Request.Url.AbsolutePath;
字符串url=Request.url.LocalPath;
如果(!System.IO.File.Exists(Context.Server.MapPath(url)))
重写路径(根文档);

}
如果您使用ASP.Net,则需要使用配置global.asax文件

private const string ROOT_DOCUMENT=“/Index.html”;
受保护的无效应用程序\u BeginRequest(对象发送方,事件参数e)
{
var path=Request.Url.AbsolutePath;
字符串url=Request.url.LocalPath;
如果(!System.IO.File.Exists(Context.Server.MapPath(url)))
重写路径(根文档);

}
你说得对,对不起。我刚刚重新编辑并尝试从路由中删除连字符,但没有任何更改。请关闭
HTML5模式
您是对的,对不起。我刚刚重新编辑并尝试从路由中删除连字符,但没有任何更改。是否关闭
html5Mode
.ASP.net?我正在使用Meteor.js和angular。试着删除hmtl5模式,然后用#尝试直接URL,然后你就会知道它是否与HTML5模式相关。可能会缩小范围。谢谢你的帮助。我只是尝试过,但即使关闭HTML5模式,也没有任何变化。我只能从主页开始浏览路线。我上面的解释为我做到了,它的工作原理和你说的一样,但如果我点击F5或键入它,它就不起作用了。我不得不从根本上对它进行排序,这解决了我的问题,因为你没有使用.net,我不能提供建议,但你上面的代码是正确的,因为我使用web api,所以请看我将$locationProvider.html5Mode(true)放在了其他地方;最后,但不确定这是否是MatterSap.net?我正在使用Meteor.js和angular。试着删除hmtl5模式,然后用#尝试直接URL,然后你就会知道它是否与HTML5模式相关。可能会缩小范围。谢谢你的帮助。我只是尝试过,但即使关闭HTML5模式,也没有任何变化。我只能从主页开始浏览路线。我上面的解释为我做到了,它的工作原理和你说的一样,但如果我点击F5或键入它,它就不起作用了。我不得不从根本上对它进行排序,这解决了我的问题,因为你没有使用.net,我不能提供建议,但你上面的代码是正确的,因为我使用web api,所以请看我将$locationProvider.html5Mode(true)放在了其他地方;最后,但不确定这是否重要