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

101
Views
angularjs async issue. how to load data from another component

I have to use "set timeout" to get the data from the parent component, so I can load it onto the page before the

I wish to replace this with a promise or async function. But I can't seem to get the syntax right.

Here is the code:

angular.
  module('fwcForms').
  component('tableFreetext', {
    templateUrl: _formPath+'/fwc-form/components/table-freetext.template.html',
    bindings: {
      model: '=',
    },
    controller: function TableFreetextController() {
      var self = this;
      this.$onInit = function() {
        setTimeout(()=>{
          self.newValue = self.model.dataRowsPlaceholder;
        },1000);
      }
    }
  });

I wish to replace:

setTimeout(()=>{
  self.newValue = self.model.dataRowsPlaceholder;
},1000);

With something like

let myPromise = new Promise(function() {
 return self.model.dataRowsPlaceholder
});

myPromise.then(data=>{
  self.newValue = self.model.dataRowsPlaceholder
});

But this does not work. It keeps saying "self.model.dataRowsPlaceholder" is 'undefined'.

about 4 years ago · Juan Pablo Isaza
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!