Get the page name from the URL in the Angular typescript page. This name will equal the mentioned name on the routing module page. You can use this for page-specific conditions.

Syntax

import { NavigationEnd, Router } from ‘@angular/router’;
import { filter } from ‘rxjs/operators’;

pageName: any = ‘’;constructor(public router: Router) {router.events.pipe(filter(event => event instanceof NavigationEnd)).subscribe((res: any) => {if (res.url != ‘/’) {this.pageName = res.url.split(‘/’).pop();this.pageName = this.pageName.split(‘?’).shift();}else {this.pageName = ‘/’;}});}

--

--

Follow the below code to implement MQTT using Javascript.

<script src=”https://cdnjs.cloudflare.com/ajax/libs/paho-mqtt/1.0.1/mqttws31.min.js" type=”text/javascript”></script><script type=”text/javascript” language=”javascript”>client = new Paho.MQTT.Client(“192.168.103.141”, 9001, “/ws”, “webdqweqe”);client.onConnectionLost = onConnectionLost;client.onMessageArrived = onMessageArrived;var myVar;// connect the clientclient.connect({ onSuccess: onConnect, onFailure: onFailure });function onFailure(e) {console.log(e);}function onConnect() {clearInterval(myVar);console.log(“onConnect”);client.subscribe(“rfidNo”);}// called when the client loses its connectionfunction onConnectionLost(responseObject) {if (responseObject.errorCode !== 0) {console.log(“onConnectionLost:” + responseObject.errorMessage);}myVar = setInterval(function () { sendTimer() }, 5000);}function sendTimer() {client.connect({ onSuccess: onConnect });}// called when a message arrivesfunction onMessageArrived(message) {console.log(“onMessageArrived:” + message.payloadString);}</script>

--

--

window.setInterval(function(){ // Set interval for checking
var date = new Date(); // Create Date object for a reference point
if(date.getHours() === 0 && date.getMinutes() === 0 && date.getSeconds() < 10){ // Check the time like above
generateSliders();}
}, 60000); // Repeat every 60000 milliseconds (1 minute)

--

--

highchart in angular by himalaya
Highchart in angular by himalaya

Step-1: Install high chart node modules from npm

npm install highcharts-angular — save
npm install highcharts — save

Step-2: put the code in the app.module.ts

import { HighchartsChartModule } from ‘highcharts-angular’;
@NgModule({imports: [HighchartsChartModule]})

Step-3: put the code in the component.html

<highcharts-chart [Highcharts]=”Highcharts” [options]=”chartOptions” [(update)]=”updateFlag” [oneToOne]=”true” style=”width: 100%; height: 130px; display: block;”></highcharts-chart>

Step-4: put the code in the component.ts

import * as Highcharts from ‘highcharts’;Highcharts: typeof Highcharts = Highcharts;
chartOptions: any;
updateFlag = false;
ngOnInit(): void {
this.chartOptions = {/*high chart code goes here…*/};
this.updateFlag = true;
}

Thank You!!! Enjoy your chart.

--

--

Method — 1

app.module.ts

import { LocationStrategy, HashLocationStrategy } from ‘@angular/common’;providers: [{provide: LocationStrategy, useClass: HashLocationStrategy}]

Method — 2

app.routing.module.ts

imports: [RouterModule.forRoot(routes, { useHash: true })],

--

--

jQuery AJAX

AJAX is the technic of exchanging data with a server and updating parts of a web page — without reloading the whole page.

Example of $.ajax():

$.ajax({type : “POST”, url : “example.txt”, dataType: “xml/html/text/script/json”,success : function(data){console.log(data);},error : function(res) {console.log(JSON.stringify(res));}});

Excample of $.get():

Syntax — $.get(URL,data,function(data,status),dataType)

$.get(“demo_test.asp”, function(data, status){alert(“Data: “ + data + “\nStatus: “ + status);});

Example of $.post():

$.post(URL,data,function(data,status),dataType)

var txt = $(“input”).val();$.post(“demo_ajax_gethint.asp”, {suggest: txt}, function(result){$(“span”).html(result);});

Other Methods:

Serialize(), serializeArray()

--

--

MongoDB Version check

If you want to check the MongoDB version in your windows system, kindly follow the below steps:

Step — 1: Open the windows command prompt by entering “cmd” in your RUN prompt.

Step — 2: Go to the “bin” folder inside the MongoDB folder in your file manager, i.e: C:\Program Files\MongoDB\Server\5.0\bin

Step — 3: Reach to the above path in your command prompt and run “mongo –version”.

Thank You…

--

--