Yes. 

On Thursday, 8 February 2018 00:31:44 UTC+5:30, Tito wrote:
>
> What does console.log(cats); 
> show in the console?
>
> On Wednesday, February 7, 2018 at 10:40:27 AM UTC-8, Rakesh Roy wrote:
>>
>> In y header component I am  using wpapi for getting the categories and 
>> want to add them to a menu in the header. this is my headercomponent
>>
>> import { Component, OnInit } from '@angular/core';
>> import { WordpressService } from '../../provider/wordpress.service';
>>
>> @Component({
>> selector: 'app-header',
>> templateUrl: './header.component.html',
>> styleUrls: ['./header.component.scss']
>> })
>> export class HeaderComponent implements OnInit {
>>
>> categories: any;
>> Wordpress: any;
>>
>> constructor(public WP: WordpressService) {
>>
>> this.Wordpress = WP.iniWp();
>>
>>
>>
>> }
>>
>> ngOnInit() {
>> this.Wordpress.categories()
>> .then(function( cats ) {
>> console.log(cats);
>> this.categories = JSON.parse(cats);
>> console.log(this.categories); // This part geting the array
>> });
>> }
>>
>> }
>>
>>
>> My Header HTML is 
>>
>> <mat-toolbar color="primary">
>>
>> <button mat-button routerLink="/">
>> <mat-icon>face</mat-icon> 
>> {{title}}
>> </button>
>> <span class="fill-remaining-space"></span>
>>
>> <button mat-button [matMenuTriggerFor]="animals">Animal index</button>
>>
>> <mat-menu #animals="matMenu" >
>>
>> <button mat-menu-item *ngFor="let category of categories">{{category.name
>> }}</button>
>> </mat-menu>
>>
>> <button mat-button fxHide="false" fxHide.gt-sm>
>> <mat-icon>menu</mat-icon>
>> </button>
>>
>> </mat-toolbar>
>>
>>
>>
>>
>>
>>
>>
>>
>> Console. no error but menu not populated in the header. Jason Example
>>
>> {
>>     "id": 54,
>>     "count": 0,
>>     "description": "",
>>     "link": "https://example.com/category/coupons/";,
>>     "name": "Coupons",
>>     "slug": "coupons",
>>     "taxonomy": "category",
>>     "parent": 0,
>>     "meta": [
>>       
>>     ],
>>     "_links": {
>>       "self": [
>>         {
>>           "href": "https://example.com/wp-json/wp/v2/categories/54";
>>         }
>>       ],
>>       "collection": [
>>         {
>>           "href": "https://example.com/wp-json/wp/v2/categories";
>>         }
>>       ],
>>       "about": [
>>         {
>>           "href": "https://example.com/wp-json/wp/v2/taxonomies/category";
>>         }
>>       ],
>>       "wp:post_type": [
>>         {
>>           "href": "https://example.com/wp-json/wp/v2/posts?categories=54";
>>         }
>>       ],
>>       "curies": [
>>         {
>>           "name": "wp",
>>           "href": "https://api.w.org/{rel}";,
>>           "templated": true
>>         }
>>       ]
>>     }
>>   }
>>
>>
>>
>>

-- 
You received this message because you are subscribed to the Google Groups 
"Angular and AngularJS discussion" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/angular.
For more options, visit https://groups.google.com/d/optout.

Reply via email to