我有一个用户列表,当您点击某个用户时,会打开一个弹出框。在该弹出框中,我想显示所选的用户名。所以通过以前的帖子 - > How to access the username out of a ng-repeat。我能够在控制台中记录所选用户名,但它不会显示在视图中
这是我的代码 - > https://gyazo.com/85d9675aff33b40995a3fc67ce97e0da
部分HTML:
<!-- START SIDEBAR -->
<div id="logo-wrap">
<img id="logo" src="assets/images/logo2.png" alt="Zazzle Logo" >
</div>
<div id="sidebar" class="md-whiteframe-z4" ng-data-color="">
<div style="height: 80px;"></div>
<div class="userList" id="usrL">
<li id="customLI" ng-repeat="user in users" id="userPos" class="active circular md-whiteframe-z2 disableDoubleClick" style="background-color: {{ user.color }} " ng-click="showPopUpDeletionConfirmation($event, user._id, user.name);" ng-data-id="{{ user._id }}">
<div ng-if="user._id==activeUser" class="wrapperImageCurrentUser" id="marker_active_user"> </div>
<p class="initials" id="userValue" style="top: {{ user.top }};" >
<custom id="user._id"></custom>
{{user.initials}}
<!-- {{user.email}} -->
</p>
<md-tooltip>{{user.name}}</md-tooltip>
</li>
</div>
</div>
<!-- END SIDEBAR -->
弹出框是一个md对话框(角度材质)。在confirmDeletion.tmpl.html文件中,我想显示所选的用户名。
<h1 class="customH1"> {{ user.name }} </h1>
app.js文件的部分代码
$scope.showPopUpDeletionConfirmation = function(ev, userId, name) {
$mdDialog.show({
controller: 'DialogDeleteUserController',
templateUrl: 'app/calendar/month/confirmDeletion.tmpl.html',
//parent: angular.element(document.body),
locals: {
userId: userId,
name: name,
},
targetEvent: ev,
hasBackdrop: false,
})
.then(function(result){
if(result) {
$scope.users = _.filter($scope.users, function(user) {
return user._id !== userId;
})
}
});
console.log('!!!!!!!!' , name);
}
从图像中可以看出 - &gt; https://gyazo.com/853685162f2aa9e6fed1d2883b54f28f(选择列表中的最后一位用户)
我正在记录所选名称,但它没有显示
我想我没有正确地将数据与视图绑定...
答案 0 :(得分:1)
.controller('DialogDeleteUserController', ['$scope','name','userId' function ($scope, name, userId) {
$scope.name = name;
$scope.userId= userId;
}])