Home  >  Q&A  >  body text

angular.js - angularjs如何通过点击事件来实现路由切换视图?

页面使用了angular的路由来切换不同的页面视图,如果不使用a标签来切换的话,使用ng-click先触发一些方法判断,然后再启动路由切换视图。这样的方式可以实现的吗?如果可以要怎么样才写语句?网上找了都没找到有靠谱的案例,麻烦各位解答一下疑惑。

淡淡烟草味淡淡烟草味2690 days ago492

reply all(2)I'll reply

  • 某草草

    某草草2017-05-15 16:59:13

    If you use ngRouter, use $location.path to switch.
    If you use uiRouter, you can use state.go

    I’m here for Amway uiRouter

    reply
    0
  • PHP中文网

    PHP中文网2017-05-15 16:59:13

    It is also possible to change the current loaction through ng-click

    reply
    0
  • Cancelreply