Angular js [ng-Route] on form submit using CodeIgniter

105 views Asked by At

I have a 2 different tabs,1st tab contains the form then after the form submit view for next tabs should get loaded and control should pass on the next tab. how to achieve it by using codeignator and angular js?

I have tabs like this

<li  id = "li1" >
<a href="#!PersonalDetails"  data-toggle="tab">Personal Details</a>
</li>
<li  id = "li2">
<a href="#!OtherDetails" data-toggle="tab">Other Details</a>
</li>

Here is angular js routing code

<script>
    var app = angular.module('myApp',['ngRoute']);
    app.config(function($routeProvider){
        $routeProvider
        .when('/',{
            templateUrl : "<?php echo base_url("Welcome/loadpersonaldetails"); ?>", 
            controller:"myCtrl"
        })
        .when('/PersonalDetails',{
            templateUrl : "<?php echo base_url("Welcome/loadpersonaldetails"); ?>",
            controller:"myCtrl"
        })
        .when('/OtherDetails',{
            templateUrl : "<?php echo base_url("Welcome/loadotherdetails"); ?>",
            controller:"myCtrl"
        })
        .otherwise({
            template : "<h1>None</h1><p>Nothing has been selected</p>"
        });
    });
</script>

Here is my form on personal details tab

<form name="myForm"  action = "<?php echo base_url('welcome/submission/');?>" method="POST">    
<input type="text"  ng-model="firstname"  name="firstname"/>
<input type="text"  ng-model="lastname"  name="lastname"/>
<input type="submit" value="Submit"/>
</form>

On click of submit button i want view of otherdetails tab to be loaded and control to pass on otherdetails tab.

 <h1>None</h1><p>Other details is now loaded</p>
0

There are 0 answers