Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/dart/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
除非NGRoutingUserPushState设置为false,否则index.html的默认视图不会出现。为什么?_Routing_Dart_Angular Dart - Fatal编程技术网

除非NGRoutingUserPushState设置为false,否则index.html的默认视图不会出现。为什么?

除非NGRoutingUserPushState设置为false,否则index.html的默认视图不会出现。为什么?,routing,dart,angular-dart,Routing,Dart,Angular Dart,考虑一个简单的index.html: 例子 ... 使用以下路由初始化代码: void routeInitializer(路由器路由器,RouteViewFactory视图工厂){ viewFactory.configure({ “你好”:我的路线( 路径:'/hello', 视图:“view/hello.html”), “默认”:ngRoute( defaultRoute:对, 路径:'/default', 视图:“view/default.html”) }); }; 访问index.h

考虑一个简单的
index.html


例子
...
使用以下路由初始化代码:

void routeInitializer(路由器路由器,RouteViewFactory视图工厂){
viewFactory.configure({
“你好”:我的路线(
路径:'/hello',
视图:“view/hello.html”),
“默认”:ngRoute(
defaultRoute:对,
路径:'/default',
视图:“view/default.html”)
});
};
访问
index.html
时不显示视图,除非我添加

.factory(NgRoutingUsePushState,
()=>新的NGRoutingUshState.value(false))

到我的
AngularModule()
初始化,在这种情况下会显示默认视图(这就是我想要的)。为什么需要添加此
NgRoutingUsePushState
配置?

这可能是
onPopState
模式实现的错误。例如,
onHashChange
在页面首次加载时不会触发事件,因此有以下行处理初始加载:

当这被实现时,
onPopState
确实在页面加载时触发了事件,因此没有必要进行相同的攻击,但这可能已经改变了。不幸的是,在当前的测试套件中没有针对这一点的测试

发件人:

浏览器倾向于在页面加载时以不同的方式处理popstate事件。Chrome和Safari总是在页面加载时发出popstate事件,但Firefox不会

这需要更仔细地调查Dart如何处理这一问题

待续

更新:


已为路由提交修复程序:

无需添加NGRoutingUshState。我已经将下面的代码片段添加到我的主控制器中,作为临时修复,直到错误得到解决。相关链接:


推送路径0.4.17请尝试一下。这解决了问题,谢谢。
import 'dart:js';
import 'dart:html';

class MainController {
  MainController(NgRoutingHelper helper) {
    Event popStateEvent = new Event.eventType('PopStateEvent', 'popstate');
    context['window'].dispatchEvent(popStateEvent);
  }
}