javascript - Returning repeated objects only if unique in Angular's ng-repeat -


I'm using funky again through some events from a JSON file. Everything is well, apart from this, I am trying to show the incident repeatedly. NG-only once in double. accident. Month gives month and day (i.e. 28 October) and event Day gives the day of the week (i.e. Tuesday)

If there are 20 incidents under Oct. 28, then I would only want to see that I have tried some different custom filters before the scene on October 28, but It can not be found properly

I have tried to choose different filters separately, but with no fate. I want this functionality, but I do not want it to leave the whole thing, I want it to expire, if that date already exists.

Any help would be greatly appreciated!

CodePen -

Here's a dummied down version of what I'm working on.

  & lt; Ul ng-repeat = "Event in Event" & gt; & Lt; Div & gt; & Lt ;! - Only the first show {{event.month}} - omit if {{event.month}} EXISTS - & gt; {{Event.day}} {{event.month}} & lt; / Div & gt; & Lt; Li & gt; & Lt; Period & gt; {{Event.time}} & lt; / Span & gt; & Lt; H2 & gt; {{Event.instructor}} & lt; / H2 & gt; & Lt; P & gt; {{Event.info}} & lt; / P & gt; & Lt; / Li & gt; & Lt; / Ul & gt;  

Assume that you want to end the performance of the month

< P> Custom filter as follows:

  app.filter ('uniqueMonth', function () {var prevVal = null; back function (input) {if (prevVal! == Input) {prevVal = input; return prevVal;}};});  

Update HTML:

  {{event.month | UniqueMonth}}  

Link to update codepe


If you want to end the entire date display, here is another link. P>

Create a custom filter below:

  app.philter ('unique date', function () {var prevVal = null; return function (input) {if (prevVal! == Input.month) {prevVal = input.month; return input.day + "" + input.month;}};});  

Update HTML:

  & lt; Ul ng-repeat = "event in event | orderby: 'datetime'" & gt; & Lt; Li & gt; & Lt; Div class = "date" & gt; {{Event | Exclusive date}} & lt; / Div & gt; & Lt; Span class = "time" & gt; {{Event.time}} & lt; / Span & gt; & Lt; / Li & gt; & Lt; / Ul & gt;  

Comments

Popular posts from this blog

java - Can't add JTree to JPanel of a JInternalFrame -

javascript - data.match(var) not working it seems -

javascript - How can I pause a jQuery .each() loop, while waiting for user input? -