0
$scope.editrc = function(id)
{
    $http.get('admissionsourcecontroller/editadID/'+id).then(function(data) {
    console.log(data);
    $scope.form = data;
});
}

I have created one angularjs function, when I click on button I gets id of that record then I'll pass to codeigniter controller

public function editadID($id)
{   
    $query = $this->db->select('Name,id')   
            ->where('MasterValueID', $id)
            ->get('blog');
    echo json_encode($query->row());
}

I have get result of that record

My view file is

<div class="modal fade" id="edit-data" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
<div class="modal-dialog" role="document">
    <div class="modal-content">
        <form method="POST" name="editItem" role="form" ng-submit="saveEdit()">
        <div class="modal-header">
            <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
            <h4 class="modal-title" id="myModalLabel">Edit Registration</h4>
        </div>
        <div class="modal-body">
            <div class="container">
                <div class="row">
                    <div class="col-xs-12 col-sm-6 col-md-6">
                        <div class="form-group">
                           <input ng-model="form.Name" type="text" placeholder="Name" name="title" class="form-control" required />
                        </div>
                    </div>
                </div>

Now I want to send all data to view for model, how ??

1
  • I think their is confusion in between model and modal Commented Apr 10, 2017 at 8:30

2 Answers 2

1

you may use JSON with $http.post

$http({
    method: 'POST',
    url: 'admissionsourcecontroller/editadID/', 
    data: form,  //this is where you set the data object you want to send
}).then(
    function(res) {
        console.log('succes !');
        //do something here
    },
    function(err) {
        console.log('error...');
    }
);
Sign up to request clarification or add additional context in comments.

1 Comment

thnx Miqe Now How I take edit model form value and pass angular saveEdit() function and then pass my codeIgniter controller function , plz describe briefly.
0

Angularjs is a client side MVC framework which runs on javascript.

Similarly, CodeIgniter is a Server side MVC Framework that runs on php.

There can be ways to pass data from angular to CIModel as you are searching for it. But the ideal way to do it, following the best practices is to not to use the CI on client side at all.

Making 2 folders

  1. Client
  2. Server

in the root of your project directory.

Setup the Angularjs in your client. Code its views controllers and factories.

Setup CI in your server folder. Configure your database with your CIModels and make different controllers on the basis of the modules you make on the client side.

Now make request from clientside factories to the server side controllers. That is, APIs.

Do the data passing by JSON or XML whatever suits you.

That will be the optimum use of both.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.