Meteor breadcrumb

瘦欲@ 提交于 2019-12-03 08:52:56

You can call Router.current().path inside a helper function and it will return the current path. Then split the path on / and return the array to your breadcrumbs template. The function is reactive, so updates will propagate:

Template.breadcrumbs.path = function() {
  return Router.current().path.split( "/" );
}

With Meteor 1.0 and Iron.Router it would be:

Template.breadcrumbs.helpers({
  path: function() {
    return Router.current().route.path(this).split( "/" );
  }
});

Note that the way of adding methods to the template engine Template.breadcrumbs.path = function() {} is deprecated.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!