小编Jas*_*eah的帖子

Angular 2如果路径不存在,如何重定向到404或其他路径

/如果角度2中不存在路径,我试图重定向404 其他路径

我尝试研究有角度1的一些方法但不是角度2.

这是我的代码:

@RouteConfig([
{
    path: '/news',
    name: 'HackerList',
    component: HackerListComponent,
    useAsDefault: true
},
{
    path: '/news/page/:page',
    name: 'TopStoriesPage',
    component: HackerListComponent
},
{
    path: '/comments/:id',
    name: 'CommentPage',
    component: HackerCommentComponent
}
])
Run Code Online (Sandbox Code Playgroud)

所以例如,如果我重定向到/news/page/它然后它工作,它返回一个空页面你如何处理这种情况发生?

javascript angular2-routing angular

75
推荐指数
5
解决办法
10万
查看次数

颤振如何在列表图中映射完成的Future对象

Future<List<Future<News>>> getNewsList(skipItems) async {
    final response = await http.get(
        'https://hacker-news.firebaseio.com/v0/topstories.json?print=pretty');

    if (response.statusCode == 200) {
      // If the call to the server was successful, parse the JSON
      var responseNewsList = json.decode(response.body);
      newsList = responseNewsList as List;
      var resNewsList = (responseNewsList as List)
          .skip(skipItems)
          .take(20)
          .map((id) =>  this.fetchNewsDetails(id))
          .toList();

      return resNewsList;
    } else {
      // If that call was not successful, throw an error.
      throw Exception('Failed to load post');
    }
}

Future<News> fetchNewsDetails(id) async {
    final response = await http.get(
        'https://hacker-news.firebaseio.com/v0/item/$id.json?print=pretty'); …
Run Code Online (Sandbox Code Playgroud)

dart flutter

1
推荐指数
1
解决办法
1786
查看次数

标签 统计

angular ×1

angular2-routing ×1

dart ×1

flutter ×1

javascript ×1