AngularJS : How do I switch views from a controller function?

前端 未结 8 595
爱一瞬间的悲伤
爱一瞬间的悲伤 2020-11-30 16:49

I am trying to use the ng-click feature of AngularJS to switch views. How would I go about doing this with the code below?

index.html

 

        
8条回答
  •  离开以前
    2020-11-30 17:12

    There are two ways for this:

    If you are using ui-router or $stateProvider, do it as:

    $state.go('stateName'); //remember to add $state service in the controller
    

    if you are using angular-router or $routeProvider, do it as:

    $location.path('routeName'); //similarily include $location service in your controller
    

提交回复
热议问题