I'm curious to know the best way to iterate through mongodb with angular to get all domains for a given customer.
Here's my JSON from MongoDB:
{
"_id": {
"$oid": "513568dae4b08eabdba2eb63"
},
"name": "Sofa King",
"contactPrimaryName": "Richard Cranium",
"contactPrimaryPhone": "410 555-1212",
"contactPrimaryEmail": "me#mysite.com",
"PrimaryAddress": "123 Any Street\nApt. 17",
"contactPrimaryCity": "Nashville",
"contactPrimaryState": "TN",
"contactPrimaryZip": "22222",
"site": "http://www.mysite.com", //ignore, replacing with domains
"domains": [
{
"url": "http://www.mysite.com",
"ns1": "ns1.mydns.com",
"ns2": "ns2.mydns.com",
"registered": "2011-01-01",
"expires": "2014-01-01"
},
{
"url": "http://www.myother.com",
"ns1": "ns1.mydns.com",
"ns2": "ns2.mydns.com",
"registered": "2012-02-02",
"expires": "2015-02-02"
}
]
I know that I can get Customer details with the following:
<tr ng-repeat="customer in customers | filter:search | orderBy:'name'">
<td>{{customer.name}}</td>
<td>{{customer.contactPrimaryName}}</td>
<td>{{customer.contactPrimaryPhone}}</td>
<td>{{customer.contactPrimaryEmail}}</td>
But I'm not sure how to get domain URLs for a given customer.
My goal is to have a customer list on one page with a button to view the domains for that customer. When viewing the domains for a given customer then having the ability to add a domain.
You should just be able to iterate over the "domains" array for the current customer:
<tr ng-repeat="customer in customers | filter:search | orderBy:'name'">
...
<td>
<div data-ng-repeat="domain in customer.domains">
// Do stuff in here with the domain for that customer
</div>
</td>
</tr>
Related
I am new to angular 4. I am working in pagination using angular 4.I ahve installed "npm install ngx-pagination --save". I followed the instruction which was in internet. But I am getting error like "The pipe 'paginate' could not be found ("
]game of games | paginate: { itemsPerPage: 2, currentPage: p }">
{{i}}
"): ng:///ActivityChartModule/ActivityComponent.html#235:32
'pagination-controls' is not a known element:". I tried More. Can any one help me to comeout from this problem. Below are my code,
app.module.ts
import {NgxPaginationModule} from 'ngx-pagination';
imports: [NgxPaginationModule]
in component.ts
p: number = 1;
games = [
{
"id": "1",
"name": "DOTA 2",
"genre": "Strategy"
},
{
"id": "2",
"name": "AOE 3",
"genre": "Strategy"
},
{
"id": "3",
"name": "GTA 5",
"genre": "RPG"
},
{
"id": "4",
"name": "Far Cry 3",
"genre": "Action"
},
{
"id": "5",
"name": "GTA San Andreas",
"genre": "RPG"
},
{
"id": "6",
"name": "Hitman",
"genre": "Action"
},
{
"id": "7",
"name": "NFS MW",
"genre": "Sport"
}, {
"id": "8",
"name": "Fifa 16",
"genre": "Sport"
}, {
"id": "9",
"name": "NFS Sen 2",
"genre": "Sport"
}, {
"id": "10",
"name": "Witcher Assasins on King",
"genre": "Adventure"
}
];
in component.html
<div class="container">
<div class="row">
<nav class="navbar">
<input class="form-control" type="text" name="search">
</nav>
<table class="table">
<thead>
<tr>
<th>#</th>
<th>Name</th>
<th>Genre</th>
</tr>
</thead>
<tbody>
<tr *ngFor="let game of games | paginate: { itemsPerPage: 2, currentPage: p }">
<td>{{i}}</td>
<td>{{game.name}}</td>
<td>{{game.genre}}</td>
</tr>
</tbody>
</table>
<div>
<pagination-controls (pageChange)="p($event)"></pagination-controls>
</div>
</div>
</div>
If you have already import NgxPaginationModule into app.module.ts, I think it is because you need to restart your project after npm install.
Try ctrl+c and ng serve to restart it again.
I resolved this problem, you need to include in your module.ts following code:
import {NgxPaginationModule} from 'ngx-pagination';
#NgModule({
imports: [ NgxPaginationModule ]
})
You should add CUSTOM_ELEMENTS_SCHEMA in angular-core
and
schemas: [ CUSTOM_ELEMENTS_SCHEMA ] ----add it in your #NgModule({})
refer this link: https://hassantariqblog.wordpress.com/2016/10/12/angular2-template-parse-errors-add-custom_elements_schema-to-the-ngmodule-schemas/
I copied your code and did not face the error you faced. However, the variable p used is actually an event and not a number[].
Replace the table and pagination-control element as per below in app.component.html:
<table class="table">
<thead>
<tr>
<th>#</th>
<th>Name</th>
<th>Genre</th>
</tr>
</thead>
<tbody>
<tr *ngFor="let game of games | paginate: { itemsPerPage: 2, currentPage: p }">
<td>{{game.id}}</td>
<td>{{game.name}}</td>
<td>{{game.genre}}</td>
</tr>
</tbody>
</table>
<div>
<pagination-controls (pageChange)="p = $event"></pagination-controls>
</div>
Also, declaring p within app.component.ts isn't required as its the paginationApi that gets used internally.
Side note: The error you are getting suggests that the ngx-pagination is not installed successfully. Please check if you have the ngx-pagination folder copied within your project's node_modules folder successfully.
Demo: https://angular-ijtgcv.stackblitz.io
Try changing the order of "import {NgxPaginationModule} from 'ngx-pagination';"
in app.module.ts
It works out for me
after importing NgxPaginationModule to app.module.ts and stop the local server 'npm update' worked for me !
Using the Google Calendar API, I can get all the attendees of the events with GET https://www.googleapis.com/calendar/v3/calendars/calendarId/events/eventId.
In my calendar event, I use an alias team#mycompany.com which sends emails to the entire team organization. Unfortunately, my calendar event returns the alias, and not the individual emails, like this:
"attendees": [
{
"email": "me#mycomapny.com",
"self": true,
"responseStatus": "accepted"
},
{
"email": "team#mycomapny.com", <-- Not what I want
"displayName": "My Entire Company",
"responseStatus": "needsAction"
},
],
How do I get the expanded list of attendees, like this:
"attendees": [
{
"email": "me#mycomapny.com",
"self": true,
"responseStatus": "accepted"
},
{
"email": "you#mycomapny.com", <-- expanded email list
"responseStatus": "needsAction"
},
{
"email": "someoneelse#mycomapny.com",
"responseStatus": "needsAction"
},
{
"email": "manager#mycomapny.com",
"responseStatus": "needsAction"
},
... etc
],
I use an alias team#mycompany.com which sends emails to the entire team organization.
If you are adding team#mycompany.com to the event then that is exactly what you are adding. Calendar has no way of knowing that email is a mailing list. If you want each person to be listed then you are going to have to add each person to the event. Google calendar can only return the information that you give it.
Answer: Don't use a mailing list when creating the event add each user. Otherwise Google calendar has no way of knowing this is a mailing list. As i see it google calendar is returning the correct data.
I've installed Facebook Pixel on my website, and it records purchases made on my site. The script on my site is the normal purchase standard event:
fbq('track', 'Purchase', {value: '0.00', currency: 'USD'});
Except that the 'value' is dynamic and changes for each order. I want to access these additional parameters using the FB Insights API (accessed through the Graph API Explorer).
Right now, my query looks like this:
act_1020149xxxxxxxxxxx/insights?level=ad&action_report_time=conversion&default_summary=true&fields=actions,spend,account_id,campaign_name,ad_name,adset_name,impressions&time_range[since]=2015-11-01&time_range[until]=2015-12-01
This returns data that looks like this:
{
"data": [
{
"actions": [
{
"action_type": "link_click",
"value": 19
},
{
"action_type": "offsite_conversion.fb_pixel_purchase",
"value": 1
},
{
"action_type": "offsite_conversion.fb_pixel_view_content",
"value": 19
},
{
"action_type": "post_like",
"value": 88
},
{
"action_type": "page_engagement",
"value": 107
},
{
"action_type": "post_engagement",
"value": 107
},
{
"action_type": "offsite_conversion",
"value": 20
}
],
"spend": 5.16,
"account_id": "10201496xxxxxxxxxx",
"campaign_name": "Link Clicks to Website (CPC)",
"ad_name": "[2015/11/27] New Arrivals",
"adset_name": "Custom Audience - Visitors or Lookalike - Visitors",
"impressions": "2634",
"date_start": "2015-11-01",
"date_stop": "2015-12-01"
}, ...
As you can see, the query returns purchases made on the site (offsite_conversion.fb_pixel_purchase) that came from the ad. How can I extend this query to also include the 'value' and 'currency' of each purchase, as captured in the standard event code embedded on my website.
If this isn't possible, then what part of the API should I use to find that data on purchases that I'm looking for?
You need to add the 'action_values' field to get the purchase value. The currency is the one you have registered with you account. If you report different currencies for different purchases (pixel fires) I would suppose that facebook convert the values to your currency.
I started learning Ionic 2 weeks ago and right now I am creating a small project to practice.You can download my project from my Github : https://github.com/KaanYildirim/ionicTest
I am trying to use tinder like cards which is created from the ionic team itself. (https://github.com/driftyco/ionic-ion-tinder-cards)
I have tried every possible solution with "track by" expression but I am still getting this error:
Error: [ngRepeat:dupes] Duplicates in a repeater are not allowed. Use 'track by' expression to specify unique keys. Repeater: card in cards track by card.id, Duplicate key: undefined, Duplicate value: undefined
I have tried to fix this error with "track by $index" and "track by card.id "(every card has an "id" attribute in .Json file) but it didn't worked. I guess that i made a small mistake and can't find it.
Can someone please help me? Thanks
index.html:
<td-cards>
<td-card ng-repeat="card in cards track by card.id" on-destroy="cardDestroyed($index)" on-swipe="cardSwiped($index)">
<div class="list card myCard">
<!-- Card Header-->
<div class="item topicDescription cardHeader">
<p>{{card.topicDescription}}</p>
</div>
<!-- Card Body-->
<div class="item item-body noBorder">
<img class="full-image" src="{{card.image}}">
<h3 class="cardTitle">{{card.title}}</h3>
<p>{{card.summary}}</p>
</div>
<!-- Card Footer-->
<div class="item tabs tabs-secondary tabs-icon-left cardFooter">
<a class="tab-item" ng-click="readMore($index)" href="#">
<i class="{{card.actionButtonIcon}}"></i>
{{card.actionButtonText}} {{card.type}} ( {{card.additionalInfo}} )
</a>
<a class="tab-item" ng-click="share($index)" href="#">
<i class="icon ion-share"></i>
Share
</a>
</div>
</div>
</td-card>
</td-cards>
Json File:
{
"articles": [
{
"id":1,
"topicDescription": "Find a Idea",
"image": "img/uber.jpg",
"title": "Uber Lowers Fares In Over 100 Cities",
"summary": "Uber is lowering prices in over 100 U.S. and Canadian cities, effective tomorrow. January is a slower month for the car service and the company says it is reducing fares in order to increase demand.",
"link": "http://techcrunch.com/2016/01/08/uber-lowers-fares-in-over-100-cities/",
"actionButtonIcon": "icon ion-ios-glasses-outline",
"actionButtonText": "Read",
"type":"Article",
"additionalInfo": "3 min"
},
{
"id":2,
"topicDescription": "Test a Idea",
"image": "img/lean.jpg",
"title": "The Lean Startup",
"summary": "Great book about startups and how to validate your idea without spending to much money and time.",
"link": "http://www.amazon.de/Lean-Startup-Innovation-Successful-Businesses/dp/0670921602/ref=sr_1_2?ie=UTF8&qid=1452779528&sr=8-2&keywords=the+lean+startup",
"actionButtonIcon": "icon ion-ios-bookmarks-outline",
"actionButtonText": "Buy",
"type":"Book",
"additionalInfo": "Amazon"
},
{
"id":3,
"topicDescription": "Build",
"image": "img/evernote.jpg",
"title": "Note Taking App",
"summary": "From short lists to lengthy research, no matter what form your writing takes, Evernote keeps you focused on moving those ideas from inspiration to completion.",
"link": "https://evernote.com/?var=3",
"actionButtonIcon": "icon ion-hammer",
"actionButtonText": "Download",
"type":"App",
"additionalInfo": "App Store"
},
{
"id":4,
"topicDescription": "Measure",
"image": "img/steve.jpg",
"title": "Steve Blank: How to Build a Great Company",
"summary": "Join Silicon Valley serial entrepreneur-turned-educator Blank in a lively discussion with Dan'l Lewin of Microsoft. This program will introduce best practices, lessons and tips that have swept the startup world, offering a wealth of proven advice and information for entrepreneurs of all stripes.",
"link": "https://www.youtube.com/watch?v=1RTcXwJuCaU",
"actionButtonIcon": "icon ion-ios-videocam-outline",
"actionButtonText": "Watch",
"type":"Video",
"additionalInfo": "Youtube"
},
{
"id":5,
"topicDescription": "Find a Idea",
"image": "img/uber.jpg",
"title": "Uber Lowers Fares In Over 100 Cities",
"summary": "Uber is lowering prices in over 100 U.S. and Canadian cities, effective tomorrow. January is a slower month for the car service and the company says it is reducing fares in order to increase demand.",
"link": "http://techcrunch.com/2016/01/08/uber-lowers-fares-in-over-100-cities/",
"actionButtonIcon": "icon ion-ios-glasses-outline",
"actionButtonText": "Read",
"type":"Article",
"additionalInfo": "3 min"
},
{
"id":6,
"topicDescription": "Test a Idea",
"image": "img/lean.jpg",
"title": "The Lean Startup",
"summary": "Great book about startups and how to validate your idea without spending to much money and time.",
"link": "http://www.amazon.de/Lean-Startup-Innovation-Successful-Businesses/dp/0670921602/ref=sr_1_2?ie=UTF8&qid=1452779528&sr=8-2&keywords=the+lean+startup",
"actionButtonIcon": "icon ion-ios-bookmarks-outline",
"actionButtonText": "Buy",
"type":"Book",
"additionalInfo": "Amazon"
},
{
"id":7,
"topicDescription": "Build",
"image": "img/evernote.jpg",
"title": "Note Taking App",
"summary": "From short lists to lengthy research, no matter what form your writing takes, Evernote keeps you focused on moving those ideas from inspiration to completion.",
"link": "https://evernote.com/?var=3",
"actionButtonIcon": "icon ion-hammer",
"actionButtonText": "Download",
"type":"App",
"additionalInfo": "App Store"
},
{
"id":8,
"topicDescription": "Measure",
"image": "img/steve.jpg",
"title": "Steve Blank: How to Build a Great Company",
"summary": "Join Silicon Valley serial entrepreneur-turned-educator Blank in a lively discussion with Dan'l Lewin of Microsoft. This program will introduce best practices, lessons and tips that have swept the startup world, offering a wealth of proven advice and information for entrepreneurs of all stripes.",
"link": "https://www.youtube.com/watch?v=1RTcXwJuCaU",
"actionButtonIcon": "icon ion-ios-videocam-outline",
"actionButtonText": "Watch",
"type":"Video",
"additionalInfo": "Youtube"
}
]
}
I examined your code. In your controllers.js file you handle the cardSwiped event by manually adding an undefined card to your list
$scope.cardSwiped = function(index) {
var newCard = // new card data
$scope.cards.push(newCard);
};
This causes your cards to have multiple undefined elements that ng-repeat will be forced to handle as duplicates. Remove/fix that handler and things should work.
BTW, this code will work normally because javascript will handle them as a single line var newCard = $scope.cards.push(newCard); This means at the end of the function your newCard variable will have the new length of the cards array.
I am trying to use the facebook registration plugin. I have it working in Firefox and Chrome, but in IE I receive the 'Can't parse fields attribute. Is it a JSON array or CSV list?'
I've found though if I take off the last custom field is fine. I tried rearranging the field order, but whenever I have over 10 fields I always get the error in IE.
My code is as follows:
iframe id='ifFacebookRego' style='margin-top: 50px' src='https://www.facebook.com/plugins/registration.php?
client_id=******&
redirect_uri=******?method=facebook&fields=[
{ "name":"name" },
{ "name":"first_name" },
{ "name":"last_name" },
{ "name":"email" },
{ "name":"nrl_team", "description":"NRL Team Interest", "type": "select", "options":{ "1":"Broncos",
"2":"Bulldogs",
"8":"Cowboys",
"11":"Dragons",
"9":"Eels",
"7":"Knights",
"10":"Panthers",
"12":"Rabbitohs",
"3": "Raiders",
"13": "Roosters",
"5":"Sea Eagles",
"4":"Sharks",
"6":"Storm",
"16":"Titans",
"15":"West Tigers",
"14":"Warriors",
"17":"Gold Coast Jnr.",
"18":"St. George Jnr.",
"19":"Parramatta Jnr.",
"20":"South Sydney Jnr.",
"21":"Manly Warringah Jnr.",
"22":"Canterbury-Banksrtown Jnr." } },
{ "name":"phone", "description":"Australian Mobile", "type":"text" },
{ "name":"cbHealthNutrition", "description": "Health Nutrition", "type":"checkbox" },
{ "name":"cbEntertainingSolutions", "description": "Entertaining Solutions", "type":"checkbox" },
{ "name":"cbEverydayIdeas", "description": "Easy Everyday Ideas", "type":"checkbox" },
{ "name":"cbHealthForFamily", "description": "Health for my Family", "type":"checkbox" },
{ "name":"gender" }]'
scrolling="auto"
frameborder="no"
style="border:none"
allowTransparency="true"
width="360"
height="650">
/iframe>
Any help would be appreciated.
Thanks.
Found the solution to this issue. Because the fields json is parse in to the iframe in the source url, the url was too long. I shortened the names of my fields and all works.