AngularJS | Hide Delete Icon on a Table after delete for that Item only










0















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..










share|improve this question




























    0















    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..










    share|improve this question


























      0












      0








      0








      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..










      share|improve this question
















      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






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Nov 14 '18 at 21:46







      Dimitris Efst

















      asked Nov 14 '18 at 21:13









      Dimitris EfstDimitris Efst

      114111




      114111






















          3 Answers
          3






          active

          oldest

          votes


















          1














          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.






          share|improve this answer






























            0














            It’s possible you have spelling error in first line, did you mean to use “deleteIten”?



            $scope.deleteIten = function (itemName) {






            share|improve this answer























            • 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


















            0














            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.






            share|improve this answer























            • 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, saying isMarkedForDeletion is not defined.

              – Dimitris Efst
              Nov 15 '18 at 8:53










            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
            );



            );













            draft saved

            draft discarded


















            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









            1














            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.






            share|improve this answer



























              1














              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.






              share|improve this answer

























                1












                1








                1







                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.






                share|improve this answer













                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.







                share|improve this answer












                share|improve this answer



                share|improve this answer










                answered Nov 15 '18 at 9:32









                Dimitris EfstDimitris Efst

                114111




                114111























                    0














                    It’s possible you have spelling error in first line, did you mean to use “deleteIten”?



                    $scope.deleteIten = function (itemName) {






                    share|improve this answer























                    • 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















                    0














                    It’s possible you have spelling error in first line, did you mean to use “deleteIten”?



                    $scope.deleteIten = function (itemName) {






                    share|improve this answer























                    • 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













                    0












                    0








                    0







                    It’s possible you have spelling error in first line, did you mean to use “deleteIten”?



                    $scope.deleteIten = function (itemName) {






                    share|improve this answer













                    It’s possible you have spelling error in first line, did you mean to use “deleteIten”?



                    $scope.deleteIten = function (itemName) {







                    share|improve this answer












                    share|improve this answer



                    share|improve this answer










                    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

















                    • 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











                    0














                    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.






                    share|improve this answer























                    • 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, saying isMarkedForDeletion is not defined.

                      – Dimitris Efst
                      Nov 15 '18 at 8:53















                    0














                    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.






                    share|improve this answer























                    • 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, saying isMarkedForDeletion is not defined.

                      – Dimitris Efst
                      Nov 15 '18 at 8:53













                    0












                    0








                    0







                    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.






                    share|improve this answer













                    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.







                    share|improve this answer












                    share|improve this answer



                    share|improve this answer










                    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, saying isMarkedForDeletion 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












                    • 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, saying isMarkedForDeletion 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

















                    draft saved

                    draft discarded
















































                    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.




                    draft saved


                    draft discarded














                    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





















































                    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







                    這個網誌中的熱門文章

                    How to read a connectionString WITH PROVIDER in .NET Core?

                    Node.js Script on GitHub Pages or Amazon S3

                    Museum of Modern and Contemporary Art of Trento and Rovereto