我需要对应用程序中的不同状态/url 使用相同的模板 url 和 Controller 。
例如:mypage.com 和 mypage.com/event 具有相同的模板网址。
.state("index", {
url: "/",
template: 'EVENTS',
controller:eventscontroller
})
.state("events", {
url: "/events",
template: 'EVENTS',
controller:eventscontroller
})
是否可以使用 ui 路由器。请帮忙
最佳答案
你可以这样做:
$state.state('main.a',{
url: '/a',
templateUrl: 'templates/tpl.html',
controller:'AController',
}
});
$state.state('main.b',{
url: '/b',
templateUrl: 'templates/tpl.html',
controller:'AController',
}
});
但我不确定为什么你想要一个 Controller 提供 2 条路线?
关于javascript - Angular ui路由器状态: same template for multiple states ,不使用参数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31980480/