Javascript 使用盎格鲁JS中继器将数据传递到基础模态中
我正在为一个网站制作一个“会员”页面,其中有3列图片和每个会员的名字。我希望能够点击图片获得更多关于该成员的信息(通过基金会的模式)。我使用了一个转发器来显示图片,但我一直在研究如何将成员数据传递到模式中,这样当我单击person a时,模式中就会有person a的数据 以下是我到目前为止的情况: 我将成员作为json列表存储在Javascript 使用盎格鲁JS中继器将数据传递到基础模态中,javascript,angularjs,zurb-foundation,Javascript,Angularjs,Zurb Foundation,我正在为一个网站制作一个“会员”页面,其中有3列图片和每个会员的名字。我希望能够点击图片获得更多关于该成员的信息(通过基金会的模式)。我使用了一个转发器来显示图片,但我一直在研究如何将成员数据传递到模式中,这样当我单击person a时,模式中就会有person a的数据 以下是我到目前为止的情况: 我将成员作为json列表存储在members.json: { “当前”:[ { “姓名”:“鲍勃”, “图片”:http://www.placehold.it/300x300", “id”:“废话”
members.json
:
{
“当前”:[
{
“姓名”:“鲍勃”,
“图片”:http://www.placehold.it/300x300",
“id”:“废话”,
“职位”:“职位1”,
“简历”:“你好,我是鲍勃”
},
{
“姓名”:“鲍比”,
“图片”:http://www.placehold.it/300x300",
“id”:“废话”,
“职位”:“职位2”,
“简历”:“你好,我是鲍比”
}
]
}
这是我的控制器,使用json文件:
var-app=angular.module('app').controller('memberCtrl',['$scope','$http',函数($scope,$http){
"严格使用",;
$http.get('/data/members.json').success(函数(数据){
$scope.members=数据;
$scope.numColumns=3;
$scope.current_rows=[];
$scope.current_rows.length=Math.ceil($scope.members.current.length/$scope.numColumns);
$scope.current_cols=[];
$scope.current_cols.length=$scope.numColumns;
});
}]);
这是我的html:
{{members.current[$parent.$index*numColumns+$index].name}
生物技术
嗨
{{members.current[$parent.$index*numColumns+$index].name}
{{members.current[$parent.$index*numColumns+$index].position}
添加ng单击img中的属性:
<img ng-src="{{members.current[$parent.$index * numColumns + $index].pic}}"
ng-click="loadMember(members.current[$parent.$index * numColumns + $index]);"/>
酷!所以在控制器函数中,我做了
$scope.memberData=member代码>在我的模式中,我尝试使用{{{memberData.bio}
访问该值。然而,我得到了
哇!原来是
引起了问题。我将ng控制器
移动到一个单独的div,它成功了!谢谢
$scope.loadMember = function (member) {
//you should be able to access the current member
console.log(member);
}