I have a table of registered users and would like to display their profile info in a modal
triggered by clicking on their <a href="#">name<a>.
Below is part of the working code via my Plunker
As in my code above, I'm currently doing the modal using Bootstrap, however I'm converting a lot of our project to Angular JS. Any JS coders familiar with how to do this?
Thanks in advance Darold
I don't know if this will answer your question but I have created a plunker demo using AngularJS
http://plnkr.co/edit/bNzolsIIm5geRd05Jaq6
HTML File code
<!DOCTYPE html>
<html ng-app="angularjs-starter">
<head lang="en">
<meta charset="utf-8">
<title>Dynamic User Profile Loading</title>
<script src="//ajax.googleapis.com/ajax/libs/angularjs/1.0.3/angular.min.js"></script>
<link rel="stylesheet" href="style.css">
<script src="app.js"></script>
</head>
<body ng-controller="MainCtrl">
<table >
<tr ng-repeat="user in users">
<td><a ng-click="getUserProfile(user)">{{user.username}}</a></td>
<td>{{user.profile.fullName}}</td>
<td>{{user.profile.email}}</td>
<td>{{user.profile.phone}}</td>
</tr>
</table>
</body>
</html>
Javascript Code
var app = angular.module('angularjs-starter', []);
app.controller('MainCtrl', function($scope) {
$scope.users =[{username: 'first'},{username: 'second'}, {username: 'third'},{username: 'fourth'}];
$scope.getUserProfile = function(user){
//Here we have received the user object so search for the object int he array
var inx = $scope.users.indexOf(user);
if(inx >= 0)
{
//retrieve user profile from server.
//Here we are going to set some values for the demo purpose
$scope.users[inx].profile = {}; //Initialize profile as an object
$scope.users[inx].profile.fullName = user.username + ' user';
$scope.users[inx].profile.email = user.username + '@example.com';
$scope.users[inx].profile.phone = user.username + ' phone';
}
};
});
I blogged about this a couple weeks ago. My blog post includes a plunkr example of doing pretty much exactly this with a twitter bootstrap modal (and no extra UI directives)
http://willvincent.com/blog/angularjs-and-twitter-bootstrap-playing-nicely