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

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

    The provided answer is absolutely correct, but I wanted to expand for any future visitors who may want to do it a bit more dynamically -

    In the view -

    Go to edit

    In the controller -

    $scope.changeView = function(person){
        var earl = '/editperson/' + person.id;
        $location.path(earl);
    }
    

    Same basic concept as the accepted answer, just adding some dynamic content to it to improve a bit. If the accepted answer wants to add this I will delete my answer.

提交回复
热议问题