title: How to fire a function from within a JSON object
body: <p>I have a function that's created from one program and then in the UI of another program, I have.  That first program builds the code and the second one renders it.</p>
  
  <p>Here's the question.</p>
  
  <p>The JSON object contains a FUNCTION as a string because that's how it's coming from the NODE SERVICE into the Angular 5.x UI</p>
  
  <p>Here's the JSON</p>
  
  <pre><code>{
    "test": {
    "trigger": "load",
    "functionName": [
             "function(){if(1 === 1){console.log('hello');} else {console.log('goodbye');}" **&lt;== CORRECTED the original single = that Johnathan caught.**
      ]
    }
  }
  </code></pre>
  
  <p>That's the simplest way I can show it.  Yes, there are "" around the {} which is INVALID JSON but the state machine we're using on the backend renders (sanitizes)  it that way and on the client.</p>
  
  <p>Bottom line: what I'm trying to achieve is the ability to call standard JavaScript functions like, onBLur, onChange, onHover, onMouseOver, etc...some functions are irrelevant...but we definitely need, onBlur and onChange.</p>
  
  <p>I did this back in Angular 1.6 with app.js and the router whereby I called functions inside a JSON object that called the function on the controller.  Wala! It was easy with <strong>$scope.$parent.functionName(arg1 if any){}</strong></p>
  
  <p>I simply wrote:</p>
  
  <pre><code>....,
  onEntry: (function() {
       do something cool here...
  }),
  ....
  </code></pre>
  
  <p>So, with TypeScript, how can I achieve the same thing?</p>
  
  <p>I hope I'm clear with my question?</p>
  
  <p>Thanks</p>
  
  <p>UPDATE!!!!</p>
  
  <p>Here's a screen shot of the DEV console capturing the ACTUAL code, sorry, last night was from memory.</p>
  
  <p><a href="https://i.stack.imgur.com/rReC5.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/rReC5.png" alt="Dev Console showing JSON with function"></a></p>
  
  <p>Hope this helps with clarification of my question.</p>