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

前端 未结 8 631
爱一瞬间的悲伤
爱一瞬间的悲伤 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:11

    Firstly you have to create state in app.js as below
    
    .state('login', {
          url: '/',
          templateUrl: 'views/login.html',
          controller: 'LoginCtrl'
        })
    
    and use below code in controller
    
     $location.path('login'); 
    

    Hope this will help you

提交回复
热议问题