我有一个注册用户的表格,并希望以模式显示他们的个人资料信息
通过点击他们的<a href="#">name<a>
触发。
以下是my Plunker
的工作代码的一部分在上面的代码中,我正在使用Bootstrap进行模态,但是我正在进行很多转换 我们的项目是Angular JS。任何JS程序员都熟悉如何做到这一点?
提前致谢 Darold
答案 0 :(得分:0)
我不知道这是否会回答您的问题,但我使用AngularJS创建了一个plunker演示
http://plnkr.co/edit/bNzolsIIm5geRd05Jaq6
HTML文件代码
<!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代码
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';
}
};
});
答案 1 :(得分:0)
http://willvincent.com/blog/angularjs-and-twitter-bootstrap-playing-nicely