我正在创建一个任务管理器但是当我显示用户名时,管理员无法像用户那样修改用户的任务:
获取任务的功能:
$scope.get = function(){
var user = $stateParams.userId;
if(user){
userService.detail({id: user}).then(function(response){
$scope.user = response;
}).catch(function(error){
notifications.error(error);
});
}
taskService.get(user).then(function(response){
$scope.tasks = response;
}).catch(function(error){
notifications.error(error);
});
};
init函数:
$scope.init = function () {
$scope.detailCategory({id: $stateParams.categoryId});
$scope.showAddTask = false;
};
html其:
<div class="all-tasks" ng-init="get()">
<div ng-show="user">
<p>Tasks from: <strong>{{user.username}}</strong></p>
</div>
<h3 class="margin-bottom-20" ng-show=(tasks|filter:{done:false}).length>Pending</h3>
<div ng-repeat="taskItem in tasks | filter:{done:false}" class="row row-margin button-show">
<div ng-hide="taskItem.is_editing">
<div class="inlineBlock">
<div ng-class="{'checkbox checkbox-circle': !user}">
<input type="checkbox" ng-hide="user" ng-change="edit(taskItem, true)" ng-model="taskItem.done">
<label class="lineBreak" ng-click="!user ? taskItem.is_editing = !taskItem.is_editing : false ">{{taskItem.name}}</label>
<span class="label label-success" ng-if="taskItem.in_progress">In progress</span>
<div class="label label-default">{{taskItem.category.name}}</div>
</div>
</div>
<div class="float-right margin-right-10">
<button type="button" class="btn btn-link btn-no-padding-top" ng-hide="user" ng-click="remove(taskItem, true)"><i class="fa fa-trash text-danger" aria-hidden="true"></i><span class="text-danger"> Delete</span> </button>
<div class="label label-primary" ng-hide="currentUser.is_superuser">Aggregate <span am-time-ago="taskItem.created_at"></span></div>
<div class="label label-primary" ng-hide="!currentUser.is_superuser">Agregada el <span>{{taskItem.created_at | amDateFormat:'D [de] MMMM [de] YYYY [a las] h:mm:ss a'}}</span></div>
<toggle-switch ng-model="taskItem.in_progress" ng-hide="user" class="switch-small switch-success show-hide" ng-change="edit(taskItem, true)" on-label="Si" off-label="No"><toggle-switch>
</div>
</div>
<div ng-if="taskItem.is_editing">
<form class="form" accept-charset="UTF-8" role="form" name="formEditTask{{taskItem.id}}" novalidate>
<div class="form-group">
<input type="text" class="form-control" ng-value="taskItem.name" focus-on-show="taskItem.is_editing" ng-model="taskItem.editName" name="task" placeholder="Task" ng-required="true" ng-blur="taskItem.is_editing = !taskItem.is_editing; taskItem.editName=''">
</div>
<button class="btn btn-primary btn-sm" ng-click="edit(taskItem, true)" ng-show="false">Edit</button>
</form>
</div>
</div>
当我修改“if”所有作品但显然用户没有显示在
任务来自: {{user.username}}
管理员只能看到任务http://i.imgur.com/GYKaP4y.png
我需要这个,就像用户一样: