Redirect after including new page in AngularJS

34 views Asked by At

I build my own form via ng-include. After you click "okay" on a page, the next one gets included.

HTML index

<form>
      <ng-include src="includedForm"></ng-include>
</form>

HTML form page 1

<input type="submit" value="Okay" ng-click="nextPage('page2.html')">

HTML form page 2

<section id="sectionOne">
      <input type="submit" value="Okay" ng-click="nextPage('page3.html')">
</section>

<section id="sectionTwo">
      <p>This is the first thing I want to see<p>
</section>

AngularJS

//default included page:
$scope.includedForm = "page1.html";

$scope.nextPage = function(page){
      $scope.includedForm = page;
}

I want the user to get redirected to sectionTwo on the second form page after clicking "okay" on the first page. Any ideas?

1

There are 1 answers

0
mindthefrequency On

use ng-switch built in directive https://docs.angularjs.org/api/ng/directive/ngSwitch