AngularJS | Hide Delete Icon on a Table after delete for that Item only
In my application for some technical reason, we need to verify before we delete an item from a table. That mean, when an item is marked for deletion, we need to hide the Trash Icon. I have it working, but the thing is it happens for the entire Table.
I want the Delete Icon to disappear only for that specific Item.
HTML:
<td ng-if="!hideTrashIcon">
<a popover-trigger="'mouseenter'" uib-popover="Delete" ng-click="deleteModal(t)">
<i class="fa fa-trash" aria-hidden="true"></i>
</a>
</td>
CTRL:
$scope.deleteIten = function (itemName)
$scope.deleting = true;
$scope.hideTrashIcon = false;
requestAPI.deleteItem(itemName).then(function success(res)
$scope.deleting = false;
$scope.hideTrashIcon = true;
$('#delete-modal').modal('hide');
var dItem = _.findIndex($scope.items, function(i) return i.itemName == itemName );
$scope.items[dItem].isMarkedForDeletion = true;
, function error(res)
$scope.deleting = false;
$scope.hideTrashIcon = false;
$('#delete-modal').modal('hide');
)
;
Apparently, I am messing up when I am calling the property. I somehow need to pass the itemName to the hideTrashIcon. Can anyone help.??? Thanks in advance..
javascript angularjs function scope
add a comment |
In my application for some technical reason, we need to verify before we delete an item from a table. That mean, when an item is marked for deletion, we need to hide the Trash Icon. I have it working, but the thing is it happens for the entire Table.
I want the Delete Icon to disappear only for that specific Item.
HTML:
<td ng-if="!hideTrashIcon">
<a popover-trigger="'mouseenter'" uib-popover="Delete" ng-click="deleteModal(t)">
<i class="fa fa-trash" aria-hidden="true"></i>
</a>
</td>
CTRL:
$scope.deleteIten = function (itemName)
$scope.deleting = true;
$scope.hideTrashIcon = false;
requestAPI.deleteItem(itemName).then(function success(res)
$scope.deleting = false;
$scope.hideTrashIcon = true;
$('#delete-modal').modal('hide');
var dItem = _.findIndex($scope.items, function(i) return i.itemName == itemName );
$scope.items[dItem].isMarkedForDeletion = true;
, function error(res)
$scope.deleting = false;
$scope.hideTrashIcon = false;
$('#delete-modal').modal('hide');
)
;
Apparently, I am messing up when I am calling the property. I somehow need to pass the itemName to the hideTrashIcon. Can anyone help.??? Thanks in advance..
javascript angularjs function scope
add a comment |
In my application for some technical reason, we need to verify before we delete an item from a table. That mean, when an item is marked for deletion, we need to hide the Trash Icon. I have it working, but the thing is it happens for the entire Table.
I want the Delete Icon to disappear only for that specific Item.
HTML:
<td ng-if="!hideTrashIcon">
<a popover-trigger="'mouseenter'" uib-popover="Delete" ng-click="deleteModal(t)">
<i class="fa fa-trash" aria-hidden="true"></i>
</a>
</td>
CTRL:
$scope.deleteIten = function (itemName)
$scope.deleting = true;
$scope.hideTrashIcon = false;
requestAPI.deleteItem(itemName).then(function success(res)
$scope.deleting = false;
$scope.hideTrashIcon = true;
$('#delete-modal').modal('hide');
var dItem = _.findIndex($scope.items, function(i) return i.itemName == itemName );
$scope.items[dItem].isMarkedForDeletion = true;
, function error(res)
$scope.deleting = false;
$scope.hideTrashIcon = false;
$('#delete-modal').modal('hide');
)
;
Apparently, I am messing up when I am calling the property. I somehow need to pass the itemName to the hideTrashIcon. Can anyone help.??? Thanks in advance..
javascript angularjs function scope
In my application for some technical reason, we need to verify before we delete an item from a table. That mean, when an item is marked for deletion, we need to hide the Trash Icon. I have it working, but the thing is it happens for the entire Table.
I want the Delete Icon to disappear only for that specific Item.
HTML:
<td ng-if="!hideTrashIcon">
<a popover-trigger="'mouseenter'" uib-popover="Delete" ng-click="deleteModal(t)">
<i class="fa fa-trash" aria-hidden="true"></i>
</a>
</td>
CTRL:
$scope.deleteIten = function (itemName)
$scope.deleting = true;
$scope.hideTrashIcon = false;
requestAPI.deleteItem(itemName).then(function success(res)
$scope.deleting = false;
$scope.hideTrashIcon = true;
$('#delete-modal').modal('hide');
var dItem = _.findIndex($scope.items, function(i) return i.itemName == itemName );
$scope.items[dItem].isMarkedForDeletion = true;
, function error(res)
$scope.deleting = false;
$scope.hideTrashIcon = false;
$('#delete-modal').modal('hide');
)
;
Apparently, I am messing up when I am calling the property. I somehow need to pass the itemName to the hideTrashIcon. Can anyone help.??? Thanks in advance..
javascript angularjs function scope
javascript angularjs function scope
edited Nov 14 '18 at 21:46
Dimitris Efst
asked Nov 14 '18 at 21:13
Dimitris EfstDimitris Efst
114111
114111
add a comment |
add a comment |
3 Answers
3
active
oldest
votes
So, to Answer my own question. Instead of using another tag, for hideTrashIcon
, I used this:
ng-if="!t.isMarkedForDeletion"
I also, put it in a span, to avoid having the line in the table disappear.
add a comment |
It’s possible you have spelling error in first line, did you mean to use “deleteIten”?
$scope.deleteIten = function (itemName) {
Thnaks for that. I just change the original code a little bit. No, in the actual code, it is fine. Thanks you though!!
– Dimitris Efst
Nov 14 '18 at 22:01
add a comment |
ng-if="!hideTrashIcon && !$scope.items[$index].isMarkedForDeletion"
Use the $index of the item in the ng-repeat of $scope.items as you generate the table rows.
Ok, I obviously do not get it. So here is my pagination:<tr dir-paginate="i in items | filter : itemName : search | orderBy:sortType:sortReverse | itemsPerPage: pageSize" >
. What is my index in this case? I tried a lot of stuff, but I can't stop hiding everything.
– Dimitris Efst
Nov 14 '18 at 22:16
On another line, I have this.ng-if="i.isMarkedForDeletion"
. So, I tried i as the index, but still doesn't work.
– Dimitris Efst
Nov 14 '18 at 22:18
What if you do:ng-if="!hideTrashIcon && !i.isMarkedForDeletion"
– user2908623
Nov 14 '18 at 22:22
Still, it makes all go away.. This is weird...
– Dimitris Efst
Nov 14 '18 at 22:27
The main problem with this is that a error is thrown, sayingisMarkedForDeletion
is not defined.
– Dimitris Efst
Nov 15 '18 at 8:53
|
show 2 more comments
Your Answer
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53308799%2fangularjs-hide-delete-icon-on-a-table-after-delete-for-that-item-only%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
3 Answers
3
active
oldest
votes
3 Answers
3
active
oldest
votes
active
oldest
votes
active
oldest
votes
So, to Answer my own question. Instead of using another tag, for hideTrashIcon
, I used this:
ng-if="!t.isMarkedForDeletion"
I also, put it in a span, to avoid having the line in the table disappear.
add a comment |
So, to Answer my own question. Instead of using another tag, for hideTrashIcon
, I used this:
ng-if="!t.isMarkedForDeletion"
I also, put it in a span, to avoid having the line in the table disappear.
add a comment |
So, to Answer my own question. Instead of using another tag, for hideTrashIcon
, I used this:
ng-if="!t.isMarkedForDeletion"
I also, put it in a span, to avoid having the line in the table disappear.
So, to Answer my own question. Instead of using another tag, for hideTrashIcon
, I used this:
ng-if="!t.isMarkedForDeletion"
I also, put it in a span, to avoid having the line in the table disappear.
answered Nov 15 '18 at 9:32
Dimitris EfstDimitris Efst
114111
114111
add a comment |
add a comment |
It’s possible you have spelling error in first line, did you mean to use “deleteIten”?
$scope.deleteIten = function (itemName) {
Thnaks for that. I just change the original code a little bit. No, in the actual code, it is fine. Thanks you though!!
– Dimitris Efst
Nov 14 '18 at 22:01
add a comment |
It’s possible you have spelling error in first line, did you mean to use “deleteIten”?
$scope.deleteIten = function (itemName) {
Thnaks for that. I just change the original code a little bit. No, in the actual code, it is fine. Thanks you though!!
– Dimitris Efst
Nov 14 '18 at 22:01
add a comment |
It’s possible you have spelling error in first line, did you mean to use “deleteIten”?
$scope.deleteIten = function (itemName) {
It’s possible you have spelling error in first line, did you mean to use “deleteIten”?
$scope.deleteIten = function (itemName) {
answered Nov 14 '18 at 21:49
bestinamirbestinamir
5917
5917
Thnaks for that. I just change the original code a little bit. No, in the actual code, it is fine. Thanks you though!!
– Dimitris Efst
Nov 14 '18 at 22:01
add a comment |
Thnaks for that. I just change the original code a little bit. No, in the actual code, it is fine. Thanks you though!!
– Dimitris Efst
Nov 14 '18 at 22:01
Thnaks for that. I just change the original code a little bit. No, in the actual code, it is fine. Thanks you though!!
– Dimitris Efst
Nov 14 '18 at 22:01
Thnaks for that. I just change the original code a little bit. No, in the actual code, it is fine. Thanks you though!!
– Dimitris Efst
Nov 14 '18 at 22:01
add a comment |
ng-if="!hideTrashIcon && !$scope.items[$index].isMarkedForDeletion"
Use the $index of the item in the ng-repeat of $scope.items as you generate the table rows.
Ok, I obviously do not get it. So here is my pagination:<tr dir-paginate="i in items | filter : itemName : search | orderBy:sortType:sortReverse | itemsPerPage: pageSize" >
. What is my index in this case? I tried a lot of stuff, but I can't stop hiding everything.
– Dimitris Efst
Nov 14 '18 at 22:16
On another line, I have this.ng-if="i.isMarkedForDeletion"
. So, I tried i as the index, but still doesn't work.
– Dimitris Efst
Nov 14 '18 at 22:18
What if you do:ng-if="!hideTrashIcon && !i.isMarkedForDeletion"
– user2908623
Nov 14 '18 at 22:22
Still, it makes all go away.. This is weird...
– Dimitris Efst
Nov 14 '18 at 22:27
The main problem with this is that a error is thrown, sayingisMarkedForDeletion
is not defined.
– Dimitris Efst
Nov 15 '18 at 8:53
|
show 2 more comments
ng-if="!hideTrashIcon && !$scope.items[$index].isMarkedForDeletion"
Use the $index of the item in the ng-repeat of $scope.items as you generate the table rows.
Ok, I obviously do not get it. So here is my pagination:<tr dir-paginate="i in items | filter : itemName : search | orderBy:sortType:sortReverse | itemsPerPage: pageSize" >
. What is my index in this case? I tried a lot of stuff, but I can't stop hiding everything.
– Dimitris Efst
Nov 14 '18 at 22:16
On another line, I have this.ng-if="i.isMarkedForDeletion"
. So, I tried i as the index, but still doesn't work.
– Dimitris Efst
Nov 14 '18 at 22:18
What if you do:ng-if="!hideTrashIcon && !i.isMarkedForDeletion"
– user2908623
Nov 14 '18 at 22:22
Still, it makes all go away.. This is weird...
– Dimitris Efst
Nov 14 '18 at 22:27
The main problem with this is that a error is thrown, sayingisMarkedForDeletion
is not defined.
– Dimitris Efst
Nov 15 '18 at 8:53
|
show 2 more comments
ng-if="!hideTrashIcon && !$scope.items[$index].isMarkedForDeletion"
Use the $index of the item in the ng-repeat of $scope.items as you generate the table rows.
ng-if="!hideTrashIcon && !$scope.items[$index].isMarkedForDeletion"
Use the $index of the item in the ng-repeat of $scope.items as you generate the table rows.
answered Nov 14 '18 at 21:58
user2908623user2908623
476
476
Ok, I obviously do not get it. So here is my pagination:<tr dir-paginate="i in items | filter : itemName : search | orderBy:sortType:sortReverse | itemsPerPage: pageSize" >
. What is my index in this case? I tried a lot of stuff, but I can't stop hiding everything.
– Dimitris Efst
Nov 14 '18 at 22:16
On another line, I have this.ng-if="i.isMarkedForDeletion"
. So, I tried i as the index, but still doesn't work.
– Dimitris Efst
Nov 14 '18 at 22:18
What if you do:ng-if="!hideTrashIcon && !i.isMarkedForDeletion"
– user2908623
Nov 14 '18 at 22:22
Still, it makes all go away.. This is weird...
– Dimitris Efst
Nov 14 '18 at 22:27
The main problem with this is that a error is thrown, sayingisMarkedForDeletion
is not defined.
– Dimitris Efst
Nov 15 '18 at 8:53
|
show 2 more comments
Ok, I obviously do not get it. So here is my pagination:<tr dir-paginate="i in items | filter : itemName : search | orderBy:sortType:sortReverse | itemsPerPage: pageSize" >
. What is my index in this case? I tried a lot of stuff, but I can't stop hiding everything.
– Dimitris Efst
Nov 14 '18 at 22:16
On another line, I have this.ng-if="i.isMarkedForDeletion"
. So, I tried i as the index, but still doesn't work.
– Dimitris Efst
Nov 14 '18 at 22:18
What if you do:ng-if="!hideTrashIcon && !i.isMarkedForDeletion"
– user2908623
Nov 14 '18 at 22:22
Still, it makes all go away.. This is weird...
– Dimitris Efst
Nov 14 '18 at 22:27
The main problem with this is that a error is thrown, sayingisMarkedForDeletion
is not defined.
– Dimitris Efst
Nov 15 '18 at 8:53
Ok, I obviously do not get it. So here is my pagination:
<tr dir-paginate="i in items | filter : itemName : search | orderBy:sortType:sortReverse | itemsPerPage: pageSize" >
. What is my index in this case? I tried a lot of stuff, but I can't stop hiding everything.– Dimitris Efst
Nov 14 '18 at 22:16
Ok, I obviously do not get it. So here is my pagination:
<tr dir-paginate="i in items | filter : itemName : search | orderBy:sortType:sortReverse | itemsPerPage: pageSize" >
. What is my index in this case? I tried a lot of stuff, but I can't stop hiding everything.– Dimitris Efst
Nov 14 '18 at 22:16
On another line, I have this.
ng-if="i.isMarkedForDeletion"
. So, I tried i as the index, but still doesn't work.– Dimitris Efst
Nov 14 '18 at 22:18
On another line, I have this.
ng-if="i.isMarkedForDeletion"
. So, I tried i as the index, but still doesn't work.– Dimitris Efst
Nov 14 '18 at 22:18
What if you do:
ng-if="!hideTrashIcon && !i.isMarkedForDeletion"
– user2908623
Nov 14 '18 at 22:22
What if you do:
ng-if="!hideTrashIcon && !i.isMarkedForDeletion"
– user2908623
Nov 14 '18 at 22:22
Still, it makes all go away.. This is weird...
– Dimitris Efst
Nov 14 '18 at 22:27
Still, it makes all go away.. This is weird...
– Dimitris Efst
Nov 14 '18 at 22:27
The main problem with this is that a error is thrown, saying
isMarkedForDeletion
is not defined.– Dimitris Efst
Nov 15 '18 at 8:53
The main problem with this is that a error is thrown, saying
isMarkedForDeletion
is not defined.– Dimitris Efst
Nov 15 '18 at 8:53
|
show 2 more comments
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53308799%2fangularjs-hide-delete-icon-on-a-table-after-delete-for-that-item-only%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown