Author: therichpost

  • WordPress query to get Woocommerce Products order by sales, pricing and rating

    WordPress query to get Woocommerce Products order by sales, pricing and rating

    Hello to all, welcome to therichpost.com. In this post, I will tell you, WordPress query to get Woocommerce Products order by sales, pricing and rating.

    If you are new in WordPress and Woocommerce then you can check my old posts related to WordPress and Woocommerce.


    Wordpress query to get Woocommerce Products order by sales, pricing and rating

    I was asked by someone to make custom query like Woocommerce default shop page orderby rating, price and popularity.

    And I am going to share this code and please use it carefully and you can use this your WordPress theme’s template file:

    1. I have used this by form post and you can try this your own way:

    <?php switch ($_POST['categoryText']){
                    case 'price':
                         $args = array(
                            'post_type'      => 'product',
                            'orderby'        => 'meta_value_num',
                            'order'          => 'asc',
                            'meta_key'       => '_price'
                            );
                        break;
                    case 'price-desc':
                        $args = array(
                            'post_type'      => 'product',
                            'orderby'        => 'meta_value_num',
                            'order'          => 'desc',
                            'meta_key'       => '_price'
                            );
                        break;
                    case 'rating':
                         $args = array(
                            'post_type'      => 'product',
                            'orderby'        => 'meta_value_num',
                            'order'          => 'desc',
                            'meta_key'       => '_wc_average_rating'
                            );
                        break;
                    case 'popularity':
                        $args = array(
                            'post_type'      => 'product',
                            'orderby'        => 'meta_value_num',
                            'order'          => 'desc',
                            'meta_key'       => 'total_sales'
                            );
                        break;
                    case 'date':
                        $args = array(
                            'post_type'      => 'product',
                            'order'          => 'desc',
                            );
                        break;
                }
            $loop = new WP_Query( $args );
            if ( $loop->have_posts() ) {
            while ( $loop->have_posts() ) : $loop->the_post();
            if(has_post_thumbnail( get_the_ID() )) { 
            $image = wp_get_attachment_image_src( get_post_thumbnail_id( get_the_ID() ));
            ?>
            <img src="<?php echo $image[0]; ?>">
            <?php } else { ?>
            <img src="<?php echo plugins_url().'/woocommerce/assets/images/placeholder.png';?>">
            <?php } ?>
            <a href="<?php echo the_permalink(get_the_ID());?>" title="<?php echo get_the_title();?>"><?php echo get_the_title();?></a>
            <?php endwhile;
        }
        wp_reset_postdata();

     

     

    If you have any query related to this post then please let me know.

    Jassa Jatt,

    Thank you

  • WordPress parse_query working example

    WordPress parse_query working example

    Hello to all, welcome to therichpost.com. In this post, I will tell you, WordPress parse_query working example.

    If you are new in WordPress, then you can check my old post related to WordPress.

    I am working in wordpress from last 4 years but everyday I find anything interesting and anything new in WordPress that I why I like it.

    Today in this post, I will tell you, how to modified or send variable to WordPress query with WordPress Filter and this is going to very interesting.

    Here is the short story on today post:
    ——————————————————–
    Today, In my WordPress Backend section. Woocommerce Products Stock Filters are not working and I was very worried for this but after some search and my mind, I made one hook to overcome this issue and I succeed and In this post, I will share this filter hook.


    Here is the working Filter and you can add this into your WordPress theme’s functions.php file:

    add_filter( 'parse_query', 'my_theme_posts_filter' );
    function my_theme_posts_filter( $query ){
        global $pagenow;
        $type = 'product';
        if (isset($_GET['post_type'])) {
            $type = $_GET['post_type'];
        }
        if ( 'product' == $type && is_admin() && $pagenow=='edit.php' && isset($_GET['stock_status']) && $_GET['stock_status'] != '') {
            $query->query_vars['meta_key'] = '_stock_status';
            $query->query_vars['meta_value'] = $_GET['stock_status'];
        }
        
    }

     

    With above hook, I made my Stock in-out again working. If you have any query related to this post, then please do comment below.

    Harjas,

    Thank you

  • Send Email in WordPress working example

    Send Email in WordPress working example

    Hello to all, welcome to therichpost.com. In this post, I will show you, Send Email in WordPress working example.

    If you are new in WordPress, then you can check my old WordPress post and WordPress tricks to get some knowledge of WordPress.

    I personally like wordpress very much and I do my mostly work in WordPress.

    Here is the working code for Send Email in WordPress working example and please follow it carefully:

    <?php
       //Mail Function
       $to        = 'YourEmailId.com';
       $subject   = "Wordpress Test Email";
       $headers   = 'Content-type: text/html;charset=utf-8' . "\r\n".'From: '. $_POST['request_email'] . "\r\n" .
       'Reply-To: ' . $_POST['request_email'] . "\r\n";
       
       $message = "Name = ".$_POST['request_name'];
       $message .= "<br />Phone =".$_POST['request_phone'];
       $message .= "<br />Email =".$_POST['request_email'];
       $message .= "<br />Comment =".$_POST['request_comment'];
       
      //Here put your Validation and send mail
       $sent = wp_mail($to, $subject, $message, $headers);
         if($sent) {
           echo "Mail Sent";
         }
         else  {
           echo "Mail did not send";
       }       
     ?>

     

    If you have any query related to this post then please do comment below.

    Harjas,

    Thank you

  • Post Author is Changed to Admin After his Post is Modified by Admin

    Post Author is Changed to Admin After his Post is Modified by Admin

    Hello to all, welcome to therichpost.com. In this post, I will tell you, how to stop Post Author is Changed to Admin After his Post is Modified by Admin.

    If you are new in WordPress then you can check my old post related to WordPress and gain some information.

    I was working in my WordPress project and that was multi vendor and when user creates the post from frontend and then admin will publish that pending post, then that post automatically goes to admin means means that post author now admin but I don’t want to this. So I made code to stop Post Author is Changed to Admin After his Post is Modified by Admin.

    Here is the code for that and you need to add this code into your functions.php file:

    <?php
    function wpdocs_run_on_publish_only( $new_status, $old_status, $post ) {
    
       if( $old_status == 'pending' ) {
            update_post_meta( $post->ID, 'original_author', $post->post_author );
    
        }
    
        if( $new_status == 'publish' ) {
             $originalAuthor = get_post_meta( $post->ID, 'original_author' );
    
             if( !empty( $originalAuthor[0] ) && $originalAuthor[0] != $post->post_author ) {
                 $postData = array(
                     'ID'           => $post->ID,
                     'post_author'  => $originalAuthor[0]
                 );
                 wp_update_post( $postData );    //May wish to check if this returns 0 for error-handling
             }
        }
    }
    add_action( 'transition_post_status', 'wpdocs_run_on_publish_only', 10, 3 );
    ?>

     

    If you have any query related to this post then please let me know.

    Jass

    Thank you

  • Angular Latest Versions Loader Working Example

    Angular Latest Versions Loader Working Example

    Hello to all, welcome to therichpost.com. In this post, I will tell you, Angular Latest Versions Loader Working Example.

    I am doing this in Angular7.2.4 version. This is very interesting post because I liked it very much.

    In this post, loader will show according to content load and this is the awesome thing.

    I am calling Angular loader before API data will load successfully and I am getting API data with Angular HTTP Client.



    Here is the working code, you need to follow carefully:


    1. Here is the code, you need to add into app.module.ts file:

    import { BrowserModule } from '@angular/platform-browser';
    import { NgModule } from '@angular/core';
    
    // we need this because we are calling API to get records
    import { HttpClientModule } from '@angular/common/http';
    import { AppComponent } from './app.component';
    
    @NgModule({
      declarations: [
        AppComponent
      ],
      imports: [
        BrowserModule,
        HttpClientModule
      ],
      providers: [],
      bootstrap: [AppComponent]
    })
    export class AppModule { }

     

    2. You need to add below code into your app.component.ts file:

    import { Component } from '@angular/core';
    // HttpClient will call the API and get data
    import { HttpClient } from '@angular/common/http';
    @Component({
      selector: 'app-root',
      templateUrl: './app.component.html',
      styleUrls: ['./app.component.css']
    })
    export class AppComponent {
      title  = 'angularloader'; //Initiate loader
      loader = true;
      post   : any;
      constructor(private http: HttpClient) {
      this.http.get('https://project/posts').subscribe(data => {
      this.post = data;
      this.loader = false;
        }, error => console.error(error));
      }
    }

     

    3. You need to add below code into app.component.html file:

    <!DOCTYPE html>
    <html lang="en">
    <head>
      <title>Bootstrap Example</title>
      <meta charset="utf-8">
      <meta name="viewport" content="width=device-width, initial-scale=1">
      <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css">
      <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
      <script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.7/umd/popper.min.js"></script>
      <script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js"></script>
    </head>
    <body>
    <div class="loader" *ngIf="loader">
      <div class="bar"></div>
    </div>
    
    <div class="jumbotron text-center">
      <h1> Welcome to {{ title }}!</h1>
      <p>Resize this responsive page to see the effect!</p> 
    </div>
      
    <div class="container">
      <div class="row">
        <ul>
         <!-- Get The API Data -->
          <li *ngFor="let Posts of post">
            <span>{{ Posts.id }}</span>
            <h2>{{ Posts.title }}</h2>
            <p>{{ Posts.body }}</p>
          </li>
        </ul>
      </div>
    </div>
    
    </body>
    </html>

     

    4. You need to add the below code into app.component.css file to styling loader:

    @keyframes loader-animation {
         0% {
             left: -100%;
         }
         49% {
             left: 100%;
         }
         50% {
             left: 100%;
         }
         100% {
             left: -100%;
         }
     }
     .loader {
         height: 5px;
         width: 100%;
         overflow: hidden;
     }
     .loader .bar {
         position: relative;
         height: 5px;
         width: 100%;
         background-color: dodgerblue;
         animation-name: loader-animation;
         animation-duration: 3s;
         animation-iteration-count: infinite;
         animation-timing-function: ease-in-out;
     }

     

    This is it, if you have any query regarding this post, then please let me know.

    Jassa Jatt

    Thank you

  • Angular 7 and above versions append element working example

    Angular 7 and above versions append element working example

    Hello to all, welcome to therichpost.com. In this post, I will tell you, Angular 7 and above versions append element working example.

    If you are new in Angular world, then you can check my old posts related to Angular.

    I am doing this in Angular 7.2.4 version and Also I used Bootstrap 4 CDN for better look.

    Angular 7 and above versions append element working example


    Here is the working code, you need follow carefully:

    1. Here is the working code, you need to add into your app.component.html file:

    <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.0/css/bootstrap.min.css">
    <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.0/js/bootstrap.min.js"></script>
    
    <div class="container">
      <h2>Form control: input</h2>
      <p>The form below contains two input elements; one of type text and one of type password:</p>
     <form id="myform">
      <div class="form-group" id="getInput">
        <label for="email">Email address:</label>
        <input type="email" class="form-control" id="email">
      </div>
      <button id="before" type="button" class="btn btn-default" (click) = "appendDiv()">Append Input</button>
    </form>
    </div>

    2. Here is the working code, you need to add into app.component.ts file:

    import { Component } from '@angular/core';
    
    @Component({
      selector: 'app-root',
      templateUrl: './app.component.html',
      styleUrls: ['./app.component.css']
    })
    export class AppComponent {
      title = 'appenddiv';
    
      appendDiv()
      {
      	var getInput   = document.getElementById('getInput').innerHTML;
      	var node       = document.createElement("div");
      	var before     = document.getElementById("before");
      	node.className = 'form-group';
      	node.innerHTML = getInput;
        var parentDiv = document.getElementById("myform");    // Get the <ul> element to insert a new node
      parentDiv.insertBefore(node, before);
      }
    }

    This is it. In my next tutorial, I will delete the append div. If you have any query related to this post, then please do comment below.

    Harjas

    Thank you

  • Laravel Rest API in Angular working example

    Laravel Rest API in Angular working example

    Hello to all, welcome to therichpost.com. In this post, I will tell you, Laravel Rest API in Angular working example.

    In this post, I am using latest versions of Angular 7.2.4, Laravel 5.8.


    Laravel Rest API in Angular working example

    Laravel Rest API in Angular working example1

    Here is the working code snippets, you need to follow carefully:

    1. Here are the commands, you need to run into your terminal to install latest Angular setup:

    $ ng new angularlaravelapi
    
    cd angularlaravelapi
    
    ng serve

    2. Here is the code, you need to add into app.module.ts file:

    import { BrowserModule } from '@angular/platform-browser';
    import { NgModule } from '@angular/core';
    
    import { AppComponent } from './app.component';
    import { HttpClientModule } from '@angular/common/http';
    
    @NgModule({
      declarations: [
        AppComponent
      ],
      imports: [
        BrowserModule,
        HttpClientModule
      ],
      providers: [],
      bootstrap: [AppComponent]
    })
    export class AppModule { }

    3. Here is the code, you need to add app.component.ts file:

    import { Component } from '@angular/core';
    import { HttpClient } from '@angular/common/http';
    @Component({
      selector: 'app-root',
      templateUrl: './app.component.html',
      styleUrls: ['./app.component.css']
    })
    export class AppComponent {
      title = 'angularlaravelapi';
      Data = new Array();
      constructor(private http: HttpClient) {
      this.http.get('http://localhost/blog/public/api/sample-restful-apis').subscribe(data => {
      this.Data.push(data);
        }, error => console.error(error));
      }
    }

    4. Here is the code, you need to add app.component.html file:

    <!DOCTYPE html>
    <html lang="en">
    <head>
      <title>Bootstrap Example</title>
      <meta charset="utf-8">
      <meta name="viewport" content="width=device-width, initial-scale=1">
      <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css">
    </head>
    <body>
    
    <div class="container">
      <h2>laravel restful api with Angular 7.2.4</h2>
      <table class="table">
        <thead>
          <tr>
            <th>Firstname</th>
            <th>Domain</th>
          </tr>
        </thead>
        <tbody>
         
          <tr class="table-success" *ngFor="let data of Data">
    
            <td>{{data.name}}</td>
            <td>{{data.domain}}</td>
    
          </tr>
        </tbody>
      </table>
    </div>
    </body>
    </html>

    5. Here is the code, you need to add routes/api.php file into you laravel setup:

    Route::get('sample-restful-apis', function()
    {
    return response()->json([
    'name' => 'test',
    'domain' => 'test.com'
    ]);
    });

    Now you are done, if you have any query related to this post, then please do comment below or ask question.

    Jassa jatt

    Thank you.

  • Angular Bootstrap Modal Form working example

    Angular Bootstrap Modal Form working example

    Hello to all, welcome to therichpost.com. In this post, I will tell you, Angular Bootstrap Modal Form working example.

    I am doing this with Angular 7.2.4, Bootstrap 4 and jquery.

    If you are new in Angular, Bootstrap and Jquery, then you can check my posts related to Angular, Bootstrap and Jquery.


    Angular Bootstrap Modal Form working example

    Angular Bootstrap Modal Form working example

    Here is the working code snippets, you need to follow carefully:


    1. Very first, you need to run below command to add default latest angular setup and other required libraries for this post:

    ng new angularpopupform
    
    cd angularpopupform
    
    npm install jquery --save
    
    npm install --save bootstrap

     

    2. Now add below code into angular.json file:

    ...
    "scripts": ["node_modules/jquery/dist/jquery.js",
               "node_modules/bootstrap/dist/js/bootstrap.min.js"]
    ...

     

     

    3. Now add below code into app.module.ts file:

    import { BrowserModule } from '@angular/platform-browser';
    import { NgModule } from '@angular/core';
    
    import { AppComponent } from './app.component';
    import { ReactiveFormsModule } from '@angular/forms';
    import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
    
    @NgModule({
      declarations: [
        AppComponent
      ],
      imports: [
        BrowserModule,
        ReactiveFormsModule,
        BrowserAnimationsModule
      ],
      providers: [],
      bootstrap: [AppComponent]
    })
    export class AppModule { }
    

     

    4. Now add below code app.component.ts file:

    <div class="container">
      <h2>POPUp Form</h2>
      <!-- Button to Open the Modal -->
      <button type="button" class="btn btn-primary" (click) = "openPopup()">
        POPUp Form
      </button>
    
      <!-- The Modal-->
      <div class="modal" id="myModal">
        <div class="modal-dialog">
          <div class="modal-content">
          
            <!-- Modal Header -->
            <div class="modal-header">
              <h4 class="modal-title">Modal Heading</h4>
              <button type="button" class="close" data-dismiss="modal">&times;</button>
            </div>
            
            <!-- Modal body -->
            <div class="modal-body">
              <form [formGroup] = "formdata" (ngSubmit)="on_submit(formdata.value)" class="form" enctype="multipart/form-data">
                <div class="form-group" [ngClass]="{error:formdata.controls.Fname.errors && formdata.controls.Fname.touched}">
                                            <label for="Inputuname">Photo Upload <span class="required-asteric">*</span></label>
                                            <div class="input-group controls">
                                              <input formControlName = "Fname" type="text" class="form-control">
    
                                              <div *ngIf="formdata.controls.Fname.errors && formdata.controls.Fname.touched" style="color:red;float: left;width: 100%;background: #ff000014;margin-top: 10px;padding: 10px 2px 0px 1px;">
                                                  <ul>
                                                     <li>Fname is required.</li>
                                                  </ul>
                                              </div>
    
                                            </div>
                                         </div>
                <button type="submit" class="btn btn-primary">Submit</button>
              </form>
    
            </div>
            
            <!-- Modal footer -->
            <div class="modal-footer">
              <button type="button" class="btn btn-danger" data-dismiss="modal">Close</button>
            </div>
            
          </div>
        </div>
      </div>
      
    </div>

    5. Now add below code into app.component.ts file:

    import { Component } from '@angular/core';
    import { FormBuilder, FormGroup, Validators, FormControl } from '@angular/forms';
    declare var $ : any;
    @Component({
      selector: 'app-root',
      templateUrl: './app.component.html',
      styleUrls: ['./app.component.css']
    })
    export class AppComponent {
      title = 'angularpopupform';
      formdata;
      openPopup()
      {
      	$("#myModal").modal("show");
      }
      ngOnInit()
      {
      	this.formdata = new FormGroup({
          Fname : new FormControl("", [Validators.required])
        });
      }
      on_submit(fordata){
            if (this.formdata.invalid) {
              Object.keys(this.formdata.controls).forEach(key => {
                this.formdata.get(key).markAsTouched();
              });
          }
          }
    
    }

    OOPS I forgot this:

    6. Now add below code into styles.css file:

     

    @import '~bootstrap/dist/css/bootstrap.min.css';

     

    Run ng serve command

    Now you are done, if you have any query related to this post, then please do comment below.

    jassa Jatt

    Thank you

  • Angular 7 Step form Working Example

    Angular 7 Step form Working Example

    Hello to all, welcome to therichpost.com. In this post, I will tell you, Angular 7 Step form Working Example.

    If you are new in Angular 7 then you can check my old posts related to Angular 7.

    In this post, I am using Angular latest version Angular 7.2.4 and Angular Material.


    Angular 7 Step form Working Example

    Angular 7 Step form Working Example2

    Here is the working code snippets you need to follow carefully:


    1. Here is the basics npm commands you need to run to install latest angular setup and angular material:

    ng new angularStepper
    
    cd angularStepper
    
    npm install --save @angular/material @angular/cdk @angular/animations
    
    ng serve

     

    2. Here is the code,  you need to add into app.module.ts file:

    import { BrowserModule } from '@angular/platform-browser';
    import { NgModule } from '@angular/core';
    import { MatStepperModule } from '@angular/material/stepper';
    import { AppComponent } from './app.component';
    import { FormsModule, ReactiveFormsModule } from '@angular/forms';
    import { MatFormFieldModule } from '@angular/material';
    import { MatInputModule } from '@angular/material';
    import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
    import { MatButtonModule } from '@angular/material/button';
    @NgModule({
      declarations: [
        AppComponent
      ],
      imports: [
        BrowserModule,
        MatStepperModule,
        FormsModule,
        ReactiveFormsModule,
        MatFormFieldModule,
        MatInputModule,
        BrowserAnimationsModule,
        MatButtonModule
      ],
      providers: [],
      bootstrap: [AppComponent]
    })
    export class AppModule { }

     

    3. Here is the code you need to add into your styles.css file:

    /* You can add global styles to this file, and also import other style files */
    @import '~@angular/material/prebuilt-themes/deeppurple-amber.css';

     

    4. Here is the code you need to add into your app.component.ts file:

    import { Component } from '@angular/core';
    import {FormBuilder, FormGroup, Validators} from '@angular/forms';
    @Component({
      selector: 'app-root',
      templateUrl: './app.component.html',
      styleUrls: ['./app.component.css']
    })
    export class AppComponent {
      title = 'angularphp';
      firstFormGroup: FormGroup;
      secondFormGroup: FormGroup;
      isOptional = false;
    
      constructor(private _formBuilder: FormBuilder) {}
    
      ngOnInit() {
        this.firstFormGroup = this._formBuilder.group({
          firstCtrl: ['', Validators.required]
        });
        this.secondFormGroup = this._formBuilder.group({
          secondCtrl: ''
        });
      }
    }

     

    5. Here is the code, you need to add into your app.component.html file:

    <link href="https://fonts.googleapis.com/icon?family=Material+Icons"rel="stylesheet">
    <button mat-raised-button (click)="isOptional = !isOptional">
      {{!isOptional ? 'Enable optional steps' : 'Disable optional steps'}}
    </button>
    <mat-horizontal-stepper linear #stepper>
      <mat-step [stepControl]="firstFormGroup">
        <form [formGroup]="firstFormGroup">
          <ng-template matStepLabel>Fill out your name</ng-template>
          <mat-form-field>
            <input matInput placeholder="Last name, First name" formControlName="firstCtrl" required>
          </mat-form-field>
          <div>
            <button mat-button matStepperNext>Next</button>
          </div>
        </form>
      </mat-step>
      <mat-step [stepControl]="secondFormGroup" [optional]="isOptional">
        <form [formGroup]="secondFormGroup">
          <ng-template matStepLabel>Fill out your address</ng-template>
          <mat-form-field>
            <input matInput placeholder="Address" formControlName="secondCtrl" required>
          </mat-form-field>
          <div>
            <button mat-button matStepperPrevious>Back</button>
            <button mat-button matStepperNext>Next</button>
          </div>
        </form>
      </mat-step>
      <mat-step>
        <ng-template matStepLabel>Done</ng-template>
        You are now done.
        <div>
          <button mat-button matStepperPrevious>Back</button>
          <button mat-button (click)="stepper.reset()">Reset</button>
        </div>
      </mat-step>
    </mat-horizontal-stepper>

     

    If you have any query related to this post then please add comment below or ask questions.

    Jassa Jatt,

    Thank you.

  • Angular 7 Tinymce working example

    Angular 7 Tinymce working example

    Hello to all, welcome to therichpost.com. In this post, I will tell you, Angular 7 Tinymce working example.

    Friends, here is tinymce update version for angular 10 and angular 11:
    Angular 10 Tinymce

    Angular 7 is getting popularity these days. If you are new in Angular then you can check my old posts related to Angular.

    Also guy’s, here you can check my Angular 11 posts: Angular 11 Tutorial


    Today I will implement TinyMCE – JavaScript Library for Rich Text Editing in Angular 7.2.4 latest version.


    Angular 7 Tinymce working example
    Angular 7 Tinymce working example

    Here is the working code snippet and you need to follow carefully:

    1. Here are some basics commands to add new Angular setup and other libraries:

    ng new angulartinymc
    
    cd angulartinymc
    
    npm i tinymce

    2. Here is code, you need to add your angular.json file:

    ...
    "styles": [
                  "node_modules/tinymce/skins/ui/oxide/skin.min.css",
                  "node_modules/tinymce/skins/ui/oxide/content.min.css",
                  "node_modules/tinymce/skins/content/default/content.min.css",
                  "src/styles.css",
    
                ],
    "scripts": [
                  "node_modules/tinymce/tinymce.min.js",
                  "node_modules/tinymce/themes/silver/theme.js"
                ]
    ...

    3. Here is the code, you need to add app.component.ts file:

    import { Component, OnInit } from '@angular/core';
    declare var tinymce: any;
    @Component({
      selector: 'app-root',
      templateUrl: './app.component.html',
      styleUrls: ['./app.component.css']
    })
    export class AppComponent {
      title = 'angulartinymc';
      ngOnInit() {
      	
      		tinymce.init(
            {
                selector: "#mymce1"
            });
      }
    }
    

    4. Here is the code, you need to add app.component.html file:

    <textarea id="mymce1"></textarea>

    In the end run ng serve command and check the output. If you have any query related to this post, then please do comment below.

    Note: Friends, In this post, I just tell the basic setup and things, you can change the code according to your requirements.

    I will appreciate that if you will tell your views for this post. Nothing matters if your views will be good or bad because with your views, I will make my next posts more good and helpful.

    Harjas,

    Thank you.