ng-repeat hide a property if its equals DateTime.MinValue

Multi tool use
Multi tool use












1















Im trying to hide cells (not the complete row) containg a date that is equal to DateTime.MinValue which is basically 0001-01-01T00:00:00.



Here is my view model:



$scope.vm.users = [
{
"Username": "user1",
"EarliestLogin": "0001-01-01T00:00:00",
"LatestLogin": "0001-01-01T00:00:00"
},
{
"Username": "user2",
"EarliestLogin": "2016-07-15T11:18:19Z",
"LatestLogin": "2016-07-15T11:18:19Z"
},
{
"Username": "user3",
"EarliestLogin": "0001-01-01T00:00:00",
"LatestLogin": "0001-01-01T00:00:00"
}
];


The table looks like that:



<table>
<tr>
<th>User Name</th>
<th>Earliest Login</th>
<th>Latest Login</th>
</tr>
<tr ng-repeat="user in vm.users">
<td>{{user.Username}}</td>
<td>{{user.EarliestLogin | date:'short'}}</td>
<td>{{user.LatestLogin | date:'short'}}</td>
</tr>
</table>




Current Output:



User Name   Earliest Login  Latest Login
user1 1/1/01 12:00 AM 1/1/01 12:00 AM
user2 7/15/16 1:18 PM 7/15/16 1:18 PM
user3 1/1/01 12:00 AM 1/1/01 12:00 AM


Desired Output:



User Name   Earliest Login  Latest Login
user1
user2 7/15/16 1:18 PM 7/15/16 1:18 PM
user3




I was able to hide the complete row using a filter on the ng-repeat but I don't know how to only hide a cell if its DateTime.MinValue...



Here is my plnkr.










share|improve this question























  • martin i am unable to understand one thing,do you want to check with Earliest Login with Latest Login or Earliest Login with DateTime.MinValue??

    – Sa E Chowdary
    Jul 15 '16 at 12:18











  • @SaE Sorry, should had clarified that more. I want to hide each Earliest Login that is equal to 0001-01-01T00:00:00, same with the Latest Login but still show the User Name

    – Martin Brandl
    Jul 15 '16 at 12:20











  • have you tried with ng-if or ng-show as one of our mate mentioned below??

    – Sa E Chowdary
    Jul 15 '16 at 12:25
















1















Im trying to hide cells (not the complete row) containg a date that is equal to DateTime.MinValue which is basically 0001-01-01T00:00:00.



Here is my view model:



$scope.vm.users = [
{
"Username": "user1",
"EarliestLogin": "0001-01-01T00:00:00",
"LatestLogin": "0001-01-01T00:00:00"
},
{
"Username": "user2",
"EarliestLogin": "2016-07-15T11:18:19Z",
"LatestLogin": "2016-07-15T11:18:19Z"
},
{
"Username": "user3",
"EarliestLogin": "0001-01-01T00:00:00",
"LatestLogin": "0001-01-01T00:00:00"
}
];


The table looks like that:



<table>
<tr>
<th>User Name</th>
<th>Earliest Login</th>
<th>Latest Login</th>
</tr>
<tr ng-repeat="user in vm.users">
<td>{{user.Username}}</td>
<td>{{user.EarliestLogin | date:'short'}}</td>
<td>{{user.LatestLogin | date:'short'}}</td>
</tr>
</table>




Current Output:



User Name   Earliest Login  Latest Login
user1 1/1/01 12:00 AM 1/1/01 12:00 AM
user2 7/15/16 1:18 PM 7/15/16 1:18 PM
user3 1/1/01 12:00 AM 1/1/01 12:00 AM


Desired Output:



User Name   Earliest Login  Latest Login
user1
user2 7/15/16 1:18 PM 7/15/16 1:18 PM
user3




I was able to hide the complete row using a filter on the ng-repeat but I don't know how to only hide a cell if its DateTime.MinValue...



Here is my plnkr.










share|improve this question























  • martin i am unable to understand one thing,do you want to check with Earliest Login with Latest Login or Earliest Login with DateTime.MinValue??

    – Sa E Chowdary
    Jul 15 '16 at 12:18











  • @SaE Sorry, should had clarified that more. I want to hide each Earliest Login that is equal to 0001-01-01T00:00:00, same with the Latest Login but still show the User Name

    – Martin Brandl
    Jul 15 '16 at 12:20











  • have you tried with ng-if or ng-show as one of our mate mentioned below??

    – Sa E Chowdary
    Jul 15 '16 at 12:25














1












1








1








Im trying to hide cells (not the complete row) containg a date that is equal to DateTime.MinValue which is basically 0001-01-01T00:00:00.



Here is my view model:



$scope.vm.users = [
{
"Username": "user1",
"EarliestLogin": "0001-01-01T00:00:00",
"LatestLogin": "0001-01-01T00:00:00"
},
{
"Username": "user2",
"EarliestLogin": "2016-07-15T11:18:19Z",
"LatestLogin": "2016-07-15T11:18:19Z"
},
{
"Username": "user3",
"EarliestLogin": "0001-01-01T00:00:00",
"LatestLogin": "0001-01-01T00:00:00"
}
];


The table looks like that:



<table>
<tr>
<th>User Name</th>
<th>Earliest Login</th>
<th>Latest Login</th>
</tr>
<tr ng-repeat="user in vm.users">
<td>{{user.Username}}</td>
<td>{{user.EarliestLogin | date:'short'}}</td>
<td>{{user.LatestLogin | date:'short'}}</td>
</tr>
</table>




Current Output:



User Name   Earliest Login  Latest Login
user1 1/1/01 12:00 AM 1/1/01 12:00 AM
user2 7/15/16 1:18 PM 7/15/16 1:18 PM
user3 1/1/01 12:00 AM 1/1/01 12:00 AM


Desired Output:



User Name   Earliest Login  Latest Login
user1
user2 7/15/16 1:18 PM 7/15/16 1:18 PM
user3




I was able to hide the complete row using a filter on the ng-repeat but I don't know how to only hide a cell if its DateTime.MinValue...



Here is my plnkr.










share|improve this question














Im trying to hide cells (not the complete row) containg a date that is equal to DateTime.MinValue which is basically 0001-01-01T00:00:00.



Here is my view model:



$scope.vm.users = [
{
"Username": "user1",
"EarliestLogin": "0001-01-01T00:00:00",
"LatestLogin": "0001-01-01T00:00:00"
},
{
"Username": "user2",
"EarliestLogin": "2016-07-15T11:18:19Z",
"LatestLogin": "2016-07-15T11:18:19Z"
},
{
"Username": "user3",
"EarliestLogin": "0001-01-01T00:00:00",
"LatestLogin": "0001-01-01T00:00:00"
}
];


The table looks like that:



<table>
<tr>
<th>User Name</th>
<th>Earliest Login</th>
<th>Latest Login</th>
</tr>
<tr ng-repeat="user in vm.users">
<td>{{user.Username}}</td>
<td>{{user.EarliestLogin | date:'short'}}</td>
<td>{{user.LatestLogin | date:'short'}}</td>
</tr>
</table>




Current Output:



User Name   Earliest Login  Latest Login
user1 1/1/01 12:00 AM 1/1/01 12:00 AM
user2 7/15/16 1:18 PM 7/15/16 1:18 PM
user3 1/1/01 12:00 AM 1/1/01 12:00 AM


Desired Output:



User Name   Earliest Login  Latest Login
user1
user2 7/15/16 1:18 PM 7/15/16 1:18 PM
user3




I was able to hide the complete row using a filter on the ng-repeat but I don't know how to only hide a cell if its DateTime.MinValue...



Here is my plnkr.







javascript html angularjs






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Jul 15 '16 at 12:08









Martin BrandlMartin Brandl

35.5k105390




35.5k105390













  • martin i am unable to understand one thing,do you want to check with Earliest Login with Latest Login or Earliest Login with DateTime.MinValue??

    – Sa E Chowdary
    Jul 15 '16 at 12:18











  • @SaE Sorry, should had clarified that more. I want to hide each Earliest Login that is equal to 0001-01-01T00:00:00, same with the Latest Login but still show the User Name

    – Martin Brandl
    Jul 15 '16 at 12:20











  • have you tried with ng-if or ng-show as one of our mate mentioned below??

    – Sa E Chowdary
    Jul 15 '16 at 12:25



















  • martin i am unable to understand one thing,do you want to check with Earliest Login with Latest Login or Earliest Login with DateTime.MinValue??

    – Sa E Chowdary
    Jul 15 '16 at 12:18











  • @SaE Sorry, should had clarified that more. I want to hide each Earliest Login that is equal to 0001-01-01T00:00:00, same with the Latest Login but still show the User Name

    – Martin Brandl
    Jul 15 '16 at 12:20











  • have you tried with ng-if or ng-show as one of our mate mentioned below??

    – Sa E Chowdary
    Jul 15 '16 at 12:25

















martin i am unable to understand one thing,do you want to check with Earliest Login with Latest Login or Earliest Login with DateTime.MinValue??

– Sa E Chowdary
Jul 15 '16 at 12:18





martin i am unable to understand one thing,do you want to check with Earliest Login with Latest Login or Earliest Login with DateTime.MinValue??

– Sa E Chowdary
Jul 15 '16 at 12:18













@SaE Sorry, should had clarified that more. I want to hide each Earliest Login that is equal to 0001-01-01T00:00:00, same with the Latest Login but still show the User Name

– Martin Brandl
Jul 15 '16 at 12:20





@SaE Sorry, should had clarified that more. I want to hide each Earliest Login that is equal to 0001-01-01T00:00:00, same with the Latest Login but still show the User Name

– Martin Brandl
Jul 15 '16 at 12:20













have you tried with ng-if or ng-show as one of our mate mentioned below??

– Sa E Chowdary
Jul 15 '16 at 12:25





have you tried with ng-if or ng-show as one of our mate mentioned below??

– Sa E Chowdary
Jul 15 '16 at 12:25












2 Answers
2






active

oldest

votes


















4














At the first glance, you can create a helper function



$scope.vm.isDateTimeMinValue = function (value) {
return value === "0001-01-01T00:00:00";
};


And use it in your template



<tr ng-repeat="user in vm.users">
<td>{{user.Username}}</td>
<td><span ng-hide="vm.isDateTimeMinValue(user.EarliestLogin)">{{user.EarliestLogin | date:'short'}}</span></td>
<td><span ng-hide="vm.isDateTimeMinValue(user.LatestLogin)">{{user.LatestLogin | date:'short'}}</span></td>
</tr>


Plunker



Note! You can define "0001-01-01T00:00:00" as an Angular JS constant using the corresponding service.






share|improve this answer


























  • This looks very clean, thanks a lot!

    – Martin Brandl
    Jul 15 '16 at 12:30



















1














Use ng-if with the condition on a span tag inside td cell, Taking that $scope.DateTime.MinValue is a cope variable with the minimum value that you require:



<tr ng-repeat="user in vm.users">
<td>{{user.Username}}</td>
<td><span ng-if="$scope.DateTime.MinValue != user.EarliestLogin">{{user.EarliestLogin | date:'short'}}</span></td>
<td><span ng-if="$scope.DateTime.MinValue != user.LatestLogin ">{{user.LatestLogin | date:'short'}}</span></td>
</tr>





share|improve this answer


























  • There is no DateTime.MinValue in JavaScript. More over, if it's supposed to use a string constant in a template, it's not a good choice.

    – Alex M
    Jul 15 '16 at 12:26






  • 1





    yeah thats not there, i expected it to be a scope variable, and in your case the issue is the '<td>' will hide away. If only one value matches , like wise if EarliestLogin matches and LatestLogin doesn't, the structure of the table will be wrecked.

    – Subrato Kumar Pati
    Jul 15 '16 at 12:32













  • i hope you get my point

    – Subrato Kumar Pati
    Jul 15 '16 at 12:35











  • Yeah, it definitely makes sense. I edited my answer, thx!

    – Alex M
    Jul 15 '16 at 12:41











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%2f38395761%2fng-repeat-hide-a-property-if-its-equals-datetime-minvalue%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























2 Answers
2






active

oldest

votes








2 Answers
2






active

oldest

votes









active

oldest

votes






active

oldest

votes









4














At the first glance, you can create a helper function



$scope.vm.isDateTimeMinValue = function (value) {
return value === "0001-01-01T00:00:00";
};


And use it in your template



<tr ng-repeat="user in vm.users">
<td>{{user.Username}}</td>
<td><span ng-hide="vm.isDateTimeMinValue(user.EarliestLogin)">{{user.EarliestLogin | date:'short'}}</span></td>
<td><span ng-hide="vm.isDateTimeMinValue(user.LatestLogin)">{{user.LatestLogin | date:'short'}}</span></td>
</tr>


Plunker



Note! You can define "0001-01-01T00:00:00" as an Angular JS constant using the corresponding service.






share|improve this answer


























  • This looks very clean, thanks a lot!

    – Martin Brandl
    Jul 15 '16 at 12:30
















4














At the first glance, you can create a helper function



$scope.vm.isDateTimeMinValue = function (value) {
return value === "0001-01-01T00:00:00";
};


And use it in your template



<tr ng-repeat="user in vm.users">
<td>{{user.Username}}</td>
<td><span ng-hide="vm.isDateTimeMinValue(user.EarliestLogin)">{{user.EarliestLogin | date:'short'}}</span></td>
<td><span ng-hide="vm.isDateTimeMinValue(user.LatestLogin)">{{user.LatestLogin | date:'short'}}</span></td>
</tr>


Plunker



Note! You can define "0001-01-01T00:00:00" as an Angular JS constant using the corresponding service.






share|improve this answer


























  • This looks very clean, thanks a lot!

    – Martin Brandl
    Jul 15 '16 at 12:30














4












4








4







At the first glance, you can create a helper function



$scope.vm.isDateTimeMinValue = function (value) {
return value === "0001-01-01T00:00:00";
};


And use it in your template



<tr ng-repeat="user in vm.users">
<td>{{user.Username}}</td>
<td><span ng-hide="vm.isDateTimeMinValue(user.EarliestLogin)">{{user.EarliestLogin | date:'short'}}</span></td>
<td><span ng-hide="vm.isDateTimeMinValue(user.LatestLogin)">{{user.LatestLogin | date:'short'}}</span></td>
</tr>


Plunker



Note! You can define "0001-01-01T00:00:00" as an Angular JS constant using the corresponding service.






share|improve this answer















At the first glance, you can create a helper function



$scope.vm.isDateTimeMinValue = function (value) {
return value === "0001-01-01T00:00:00";
};


And use it in your template



<tr ng-repeat="user in vm.users">
<td>{{user.Username}}</td>
<td><span ng-hide="vm.isDateTimeMinValue(user.EarliestLogin)">{{user.EarliestLogin | date:'short'}}</span></td>
<td><span ng-hide="vm.isDateTimeMinValue(user.LatestLogin)">{{user.LatestLogin | date:'short'}}</span></td>
</tr>


Plunker



Note! You can define "0001-01-01T00:00:00" as an Angular JS constant using the corresponding service.







share|improve this answer














share|improve this answer



share|improve this answer








edited Jul 15 '16 at 12:41

























answered Jul 15 '16 at 12:20









Alex MAlex M

2,38071928




2,38071928













  • This looks very clean, thanks a lot!

    – Martin Brandl
    Jul 15 '16 at 12:30



















  • This looks very clean, thanks a lot!

    – Martin Brandl
    Jul 15 '16 at 12:30

















This looks very clean, thanks a lot!

– Martin Brandl
Jul 15 '16 at 12:30





This looks very clean, thanks a lot!

– Martin Brandl
Jul 15 '16 at 12:30













1














Use ng-if with the condition on a span tag inside td cell, Taking that $scope.DateTime.MinValue is a cope variable with the minimum value that you require:



<tr ng-repeat="user in vm.users">
<td>{{user.Username}}</td>
<td><span ng-if="$scope.DateTime.MinValue != user.EarliestLogin">{{user.EarliestLogin | date:'short'}}</span></td>
<td><span ng-if="$scope.DateTime.MinValue != user.LatestLogin ">{{user.LatestLogin | date:'short'}}</span></td>
</tr>





share|improve this answer


























  • There is no DateTime.MinValue in JavaScript. More over, if it's supposed to use a string constant in a template, it's not a good choice.

    – Alex M
    Jul 15 '16 at 12:26






  • 1





    yeah thats not there, i expected it to be a scope variable, and in your case the issue is the '<td>' will hide away. If only one value matches , like wise if EarliestLogin matches and LatestLogin doesn't, the structure of the table will be wrecked.

    – Subrato Kumar Pati
    Jul 15 '16 at 12:32













  • i hope you get my point

    – Subrato Kumar Pati
    Jul 15 '16 at 12:35











  • Yeah, it definitely makes sense. I edited my answer, thx!

    – Alex M
    Jul 15 '16 at 12:41
















1














Use ng-if with the condition on a span tag inside td cell, Taking that $scope.DateTime.MinValue is a cope variable with the minimum value that you require:



<tr ng-repeat="user in vm.users">
<td>{{user.Username}}</td>
<td><span ng-if="$scope.DateTime.MinValue != user.EarliestLogin">{{user.EarliestLogin | date:'short'}}</span></td>
<td><span ng-if="$scope.DateTime.MinValue != user.LatestLogin ">{{user.LatestLogin | date:'short'}}</span></td>
</tr>





share|improve this answer


























  • There is no DateTime.MinValue in JavaScript. More over, if it's supposed to use a string constant in a template, it's not a good choice.

    – Alex M
    Jul 15 '16 at 12:26






  • 1





    yeah thats not there, i expected it to be a scope variable, and in your case the issue is the '<td>' will hide away. If only one value matches , like wise if EarliestLogin matches and LatestLogin doesn't, the structure of the table will be wrecked.

    – Subrato Kumar Pati
    Jul 15 '16 at 12:32













  • i hope you get my point

    – Subrato Kumar Pati
    Jul 15 '16 at 12:35











  • Yeah, it definitely makes sense. I edited my answer, thx!

    – Alex M
    Jul 15 '16 at 12:41














1












1








1







Use ng-if with the condition on a span tag inside td cell, Taking that $scope.DateTime.MinValue is a cope variable with the minimum value that you require:



<tr ng-repeat="user in vm.users">
<td>{{user.Username}}</td>
<td><span ng-if="$scope.DateTime.MinValue != user.EarliestLogin">{{user.EarliestLogin | date:'short'}}</span></td>
<td><span ng-if="$scope.DateTime.MinValue != user.LatestLogin ">{{user.LatestLogin | date:'short'}}</span></td>
</tr>





share|improve this answer















Use ng-if with the condition on a span tag inside td cell, Taking that $scope.DateTime.MinValue is a cope variable with the minimum value that you require:



<tr ng-repeat="user in vm.users">
<td>{{user.Username}}</td>
<td><span ng-if="$scope.DateTime.MinValue != user.EarliestLogin">{{user.EarliestLogin | date:'short'}}</span></td>
<td><span ng-if="$scope.DateTime.MinValue != user.LatestLogin ">{{user.LatestLogin | date:'short'}}</span></td>
</tr>






share|improve this answer














share|improve this answer



share|improve this answer








edited Jan 2 at 11:23









Alexander The Second

276




276










answered Jul 15 '16 at 12:21









Subrato Kumar PatiSubrato Kumar Pati

365




365













  • There is no DateTime.MinValue in JavaScript. More over, if it's supposed to use a string constant in a template, it's not a good choice.

    – Alex M
    Jul 15 '16 at 12:26






  • 1





    yeah thats not there, i expected it to be a scope variable, and in your case the issue is the '<td>' will hide away. If only one value matches , like wise if EarliestLogin matches and LatestLogin doesn't, the structure of the table will be wrecked.

    – Subrato Kumar Pati
    Jul 15 '16 at 12:32













  • i hope you get my point

    – Subrato Kumar Pati
    Jul 15 '16 at 12:35











  • Yeah, it definitely makes sense. I edited my answer, thx!

    – Alex M
    Jul 15 '16 at 12:41



















  • There is no DateTime.MinValue in JavaScript. More over, if it's supposed to use a string constant in a template, it's not a good choice.

    – Alex M
    Jul 15 '16 at 12:26






  • 1





    yeah thats not there, i expected it to be a scope variable, and in your case the issue is the '<td>' will hide away. If only one value matches , like wise if EarliestLogin matches and LatestLogin doesn't, the structure of the table will be wrecked.

    – Subrato Kumar Pati
    Jul 15 '16 at 12:32













  • i hope you get my point

    – Subrato Kumar Pati
    Jul 15 '16 at 12:35











  • Yeah, it definitely makes sense. I edited my answer, thx!

    – Alex M
    Jul 15 '16 at 12:41

















There is no DateTime.MinValue in JavaScript. More over, if it's supposed to use a string constant in a template, it's not a good choice.

– Alex M
Jul 15 '16 at 12:26





There is no DateTime.MinValue in JavaScript. More over, if it's supposed to use a string constant in a template, it's not a good choice.

– Alex M
Jul 15 '16 at 12:26




1




1





yeah thats not there, i expected it to be a scope variable, and in your case the issue is the '<td>' will hide away. If only one value matches , like wise if EarliestLogin matches and LatestLogin doesn't, the structure of the table will be wrecked.

– Subrato Kumar Pati
Jul 15 '16 at 12:32







yeah thats not there, i expected it to be a scope variable, and in your case the issue is the '<td>' will hide away. If only one value matches , like wise if EarliestLogin matches and LatestLogin doesn't, the structure of the table will be wrecked.

– Subrato Kumar Pati
Jul 15 '16 at 12:32















i hope you get my point

– Subrato Kumar Pati
Jul 15 '16 at 12:35





i hope you get my point

– Subrato Kumar Pati
Jul 15 '16 at 12:35













Yeah, it definitely makes sense. I edited my answer, thx!

– Alex M
Jul 15 '16 at 12:41





Yeah, it definitely makes sense. I edited my answer, thx!

– Alex M
Jul 15 '16 at 12:41


















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%2f38395761%2fng-repeat-hide-a-property-if-its-equals-datetime-minvalue%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







K0g0SZaoIkP8IZfgnSt,y,j1FO9An uYG2
pEBmdO

Popular posts from this blog

Monofisismo

Angular Downloading a file using contenturl with Basic Authentication

Olmecas