Solved

AngularJS Chaining IF Statement

Posted on 2014-10-24
1
111 Views
Last Modified: 2014-11-18
I'm attempting to chain a group of variables to create a single IF statement. If I run each statement individually, I will get the expected results. Is there a better way to accomplish this?

                var upcomingDate = moment(object["upcomingdate"]);
                var monthlyDateFuture = moment().diff(upcomingDate, 'days') > 30 && object["Frequency"] == 'monthly';
                var biWeeklyFuture = moment().diff(upcomingDate, 'days') > 14 && object["Frequency"] == 'biweekly';
                var weeklyFuture = moment().diff(upcomingDate, 'days') > 7 && object["Frequency"] == 'weekly';
                var biMonthlyFuture = moment().diff(upcomingDate, 'days') > 60 && object["Frequency"] == 'bimonthly';
                var quarterlyFuture = moment().diff(upcomingDate, 'days') > 90 && object["Frequency"] == 'quarterly';

                if (monthlyDateFuture && biWeeklyFuture && weeklyFuture && biMonthlyFuture && quarterlyFuture) {
                       $scope.summary[segment].totalLateRelationships++;
                       $scope.summary[segment].lateRelationships.push(object);    
                }

Open in new window

0
Comment
Question by:brendanlefavre
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 82

Accepted Solution

by:
leakim971 earned 500 total points
ID: 40403931
look like you need OR operators not AND :
if (monthlyDateFuture || biWeeklyFuture || weeklyFuture || biMonthlyFuture || quarterlyFuture) {

Open in new window

0

Featured Post

Secure Your WordPress Site: 5 Essential Approaches

WordPress is the web's most popular CMS, but its dominance also makes it a target for attackers. Our eBook will show you how to:

Prevent costly exploits of core and plugin vulnerabilities
Repel automated attacks
Lock down your dashboard, secure your code, and protect your users

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

When it comes to write a Context Sensitive Help (an online help that is obtained from a specific point in state of software to provide help with that state) ,  first we need to make the file that contains all topics, which are given exclusive IDs. …
Learn by example how to specify CSS selectors for Selenium WebDriver test automation software.
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The is a quite short video tutorial. In this video, I'm going to show you how to create self-host WordPress blog with free hosting service.

691 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question