Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

181
Views
How to import functions or variables from node.js file in AngularJs or Angular?

Hi I am working with IOTA distributed ledger. I have iota client library for node.js. I want to read data from node.js file where I access IOTA distributed ledgers and pass it to Html where user can see.

My client.js file:

const Iota = require('@iota/core');
const Extract = require('@iota/extract-json');
const iota = Iota.composeAPI({
    provider: 'https://nodes.devnet.iota.org:443'
    });
let x = [];
iota.getBundlesFromAddresses(['PXMPEGYZCOVEOSRAUXY9VYRBHJBSDWORWQNBDJRVEFTMXZWLTQZSPHEUDMXT9YKGPMMSVDSNHSJNWQUOX'])
.then(bundle => {
    for (let i = 0; i < bundle.length; i++) {
        console.log(JSON.parse(Extract.extractJson(bundle[i])).message);
        x[i]=JSON.parse(Extract.extractJson(bundle[i])).message;
        } 
})
.catch(err => {
    console.error(err);
});

I want to pass x[i] variable to html.

<!DOCTYPE html>
<html>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.6.9/angular.min.js"></script>
<body>

<div ng-app="myApp" ng-controller="client">
    {{ x[0]}}
    {{ x[1]}}
    {{ x[2]}}
</div>

<script src="myApp.js"></script>
<script src="client.js"></script>

</body>
</html> 

I know how to read data from controller but how am I gonna read data if client.js has imported libraries. I tried in Angular to convert libraries to typescript but couldnt figure out.

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

This is typically done in package.json, such as server or build

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!