I need help converting this code to AngularJS. The current code is in core JavaScript and I want to call a core JavaScript constructor from AngularJS. I have successfully defined how to call the service constructor in core, but I am unsure of how to call it from AngularJS. If anyone has any suggestions, please let me know.
In the data-ng-init, I would like to call the service constructor as follows: new service
Core JavaScript
(function(){
service = new service({
on_connection_init : connectingIndicator,
on_connection_inprogress : connectingProgress,
on_connection_complete : connectedIndicator,
on_connection_close : closedIndicator
});
service.submit("service_demo_keys", {});
});
/*AngularJS*/
var app = angular.module('service', []);
app.controller('sendtocluster', function($scope) {
$scope.name = "connecting to service....";
});
<div ng-app="service" ng-controller="sendtocluster" data-ng-init="names=[{on_connection_init : 'connectingIndicator',on_connection_inprogress : 'connectingProgress',on_connection_complete : 'connectedIndicator',on_connection_close : 'closedIndicator'}]">
<p>Name : <input type="text" ng-model="name"></p>
<h1>Response:- {{name}}</h1>
<li data-ng-repeat="myObject in names">
{{myObject.on_connection_init}} -
{{ myObject.on_connection_inprogress}}</li>