1

index.html

<body ng-app="myApp" ng-controller="myCtrl">
    <div view-users id="viewuserdiv"></div>
</body>

Here is the angular js code to load the another html page into the div of id viewuserdiv.

var app = angular.module('myApp',[]);
app.directive('viewUsers',function(){
    return{
        templateUrl:"viewuser.html"
    }
});

here is my viewuser.html

<table>
    <thead>
        <td>User Name</td>
        <td>Mobile Number</td>
        <td>Action</td>
    </thead>
    <tbody>
        <td>Sam</td>
        <td>4562147554</td>
        <td><input type="button" value="View" id="updateUser" name="updateUser"></td>
    </tbody>
</table>

Now after view is loaded i need to load another view i.e; update.php when "updateUser" button is clicked without refreshing the page.

update.php

<form action ="" method="POST">
    User Name:<input type="text" id="uname" name="uname"/>
    Mobile Number:<input type="text" id="uname" name="uname"/>
    <input type="button" name="updatebtn" id="updatebtn" value="Update"/>
</form>

Is there is any way to do it by custom directives itself.

priya singh
  • 23
  • 1
  • 2
  • I think you need a routing module, like `ngRoute` or `ui.router` (better with nested views). (Also why do you need a `.php` file? You can use `ng-submit` on your form too) – Aleksey Solovey Oct 29 '18 at 09:38

0 Answers0