I have this Schema in mongoDB:
var CostSchema = new Schema({
item: String,
value: Number
});
var AttachmentsSchema = new Schema({
item: String,
url: String
})
var ServiceSchema = new Schema({
item: String, // maybe another Schema [] to be able to search for this criteria
description:String,
worker: { type: Schema.Types.ObjectId, ref:'Worker'}, //Saves Worker ID
date_assigned: Date,
price:Number
});
var JobsSchema = new Schema({
manager: { type: Schema.Types.ObjectId, ref:'Admin', required:true}, // Saves Manager Name
propertie: { type: Schema.Types.ObjectId, ref: 'Propertie', required:true}, //Saves Property Name
unit: String,
completed: Boolean,
costs: [CostSchema],
services:[ServiceSchema],
totalPrice: Number,
totalCost:Number,
poNumber: { type : String, unique: true, sparse:true },
invoiceNumber: { type : String, unique: true, sparse:true },
notes: String,
date_completed: Date,
attachments: [AttachmentsSchema],
notification_sent: Boolean
});
So depending on the Job it will have a completed date or not i am trying to apply the following filter in the front-end
<div class="page-header col-xs-12">
<h3 class ='text-center'>Pending Jobs</h3>
<div class="form-group col-xs-8 col-xs-offset-2 text-center">
<label for="searchJobBox1">Filter</label>
<input ng-model = 'job.$' type="text" class="form-control" id="searchJobBox1" placeholder="Quick Filter...">
</div>
<div class="form-group col-xs-2 col-xs-offset-3 text-center">
<label for="jobPropertyFilter" class="col-xs-2 control-label">Property</label>
<div>
<select ng-model = 'job.propertie._id' class="form-control" id='jobPropertyFilter'>
<option></option>
<option value = '{{property._id}}' ng-repeat ='property in properties'>
{{property.name}}
</option>
</select>
</div>
</div>
<div class="form-group col-xs-2 text-center">
<label for="jobWorkerFilter" class="col-xs-2 control-label">Worker</label>
<div>
<select ng-model = 'job.services.worker._id' class="form-control" id='jobWorkerFilter'>
<option></option>
<option value = '{{worker._id}}' ng-repeat ='worker in workers'>
{{worker.first}} {{worker.last}}
</option>
</select>
</div>
</div>
<div class="form-group col-xs-2 text-center">
<label for="jobManagerFilter" class="col-xs-2 control-label">Manager</label>
<div>
<select ng-model = 'job.manager._id' class="form-control" id='jobManagerFilter'>
<option></option>
<option value = '{{admin._id}}' ng-repeat ='admin in admins'>
{{admin.first}} {{admin.last}}
</option>
</select>
</div>
</div>
</div>
I have two ng-repeats in place as follows: 1) Is Working Perfectly
<div class="panel panel-default" ng-repeat = 'job in jobs| filter:job:strict' ng-if='!job.date_completed' >
2)
<div class="panel panel-default" ng-repeat = 'job in jobs| filter:job:strict' ng-if='job.date_completed' >
For some reason that i haven't been able to figure out, Angular will apply the filter to every job with a date_completed property and they are not being displayed it does not have anything to do with the ng-if, which is working just fine.
Any advice?