Solved

AngularJS Chaining IF Statement

Posted on 2014-10-24
1
95 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
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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Having worked on larger scale sites, we found out that you are bound to look at more scalable solutions to integrating widgets, code snippets or complete applications and mesh them into functional sites, in any given composition. To share some of…
Using SQL Scripts we can save all the SQL queries as files that we use very frequently on our database later point of time. This is one of the feature present under SQL Workshop in Oracle Application Express.
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

705 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

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now