DZone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Newsletter
Log In / Join
Refcards Trend Reports
Events Video Library
Refcards
Trend Reports

Events

View Events Video Library

Related

  • Building Enterprise Authentication With Angular, Spring Boot, SSO, and MFA
  • Zone-Free Angular: Unlocking High-Performance Change Detection With Signals and Modern Reactivity
  • When Angular APIs Return 200 but the Frontend Is Already Failing Users
  • Why Angular Performance Problems Are Often Backend Problems

Trending

  • DZone's Article Submission Guidelines
  • How to Submit a Post to DZone
  • How Did We Go From ChatGPT to Autonomous AI Agents in Just Four Years?
  • Getting Started With Qdrant: Building Intelligent Search Applications With Java

Draft This article hasn't been published, so readers can't see it.

In moderation This article is waiting for review, so readers can't see it yet.

Deleted This article has been deleted, so readers can't see it.

  1. DZone
  2. Coding
  3. Frameworks
  4. Integrating an AngularJS Component in Mule

Integrating an AngularJS Component in Mule

If you can create a flow where an HTTP static resource handler can be used, then you can integrate an AngularJS component in Mule.

By 
Anurag Dwivedi
·
Jan. 21, 17 · Opinion
Post on X (opens in a new tab) Share on LinkedIn (opens in a new tab)
8.0K Views

Join the DZone community Save articles, join the discussion, and download Refcards and Trend Reports with a free account.

Join for free Already a member? Log in

Imagine a situation in which we need to integrate an AngularJS component with an existing Mule application. The first thing we have to do is create an AngularJS project in /src/main/app folder.

This will be like a normal web call to your Mule service. I have added an HTML component where the Angular code is embedded.

I have attached the code below that I have used for creating the HTML component.

<!DOCTYPE html>
<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.27/angular.min.js"></script>
<script type="text/javascript" src="main.js" defer></script>
<meta charset="utf-8">
<title>JS Bin</title>
</head>
<body ng-app="myAppModule">
<div ng-controller="myAppController" style="text-align: center">

<button ng-click="calculateQuantity()">Calculate</button>

</div>
<script>
var myAppModule = angular.module('myAppModule', []);
myAppModule.controller('myAppController', function ($scope, $http) {
var CelsiusVal = "10";
$scope.calculateQuantity = function () {
alert("I'm here")
$http.get('http://localhost:8081/flow2', { params: { Celsius: CelsiusVal } }).
success(function (data) {alert("succ");})
.error(function () { alert("error"); }); 
};
});
</script>
</body>
</html>  

After that, in next step, we have to create a flow where an HTTP static resource handler can be used. This component will be used to parse our Angular code.

Find the Mule code I have used for this integration below.

<?xml version="1.0" encoding="UTF-8"?>

<mule xmlns:http="http://www.mulesoft.org/schema/mule/http" xmlns="http://www.mulesoft.org/schema/mule/core" xmlns:doc="http://www.mulesoft.org/schema/mule/documentation"
xmlns:spring="http://www.springframework.org/schema/beans" 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-current.xsd
http://www.mulesoft.org/schema/mule/core http://www.mulesoft.org/schema/mule/core/current/mule.xsd
http://www.mulesoft.org/schema/mule/http http://www.mulesoft.org/schema/mule/http/current/mule-http.xsd">
<http:listener-config name="HTTP_Listener_Configuration" host="localhost" port="8081" doc:name="HTTP Listener Configuration"/>
<flow name="testangularFlow">
<http:listener config-ref="HTTP_Listener_Configuration" path="/flow1" doc:name="HTTP"/>
<logger level="INFO" doc:name="Logger"/>
<http:static-resource-handler resourceBase="${app.home}/ui" defaultFile="Ui.html" doc:name="HTTP Static Resource Handler"/>
<set-payload value="#[payload]" doc:name="Set Payload"/>
</flow>
<flow name="testangularFlow1">
<http:listener config-ref="HTTP_Listener_Configuration" path="/flow2" doc:name="HTTP"/>
<set-payload value="In Second Flow" doc:name="Set Payload"/>
</flow>
</mule>

You have now successfully integrated Mule with Angular JS.

AngularJS

Opinions expressed by DZone contributors are their own.

Related

  • Building Enterprise Authentication With Angular, Spring Boot, SSO, and MFA
  • Zone-Free Angular: Unlocking High-Performance Change Detection With Signals and Modern Reactivity
  • When Angular APIs Return 200 but the Frontend Is Already Failing Users
  • Why Angular Performance Problems Are Often Backend Problems

Partner Resources

×

Comments

Loading comments

The comments didn't load

Please try again in a moment.

Likes

Loading

The next likes didn't load. Please try again.

The likes didn't load

Please try again in a moment.

See who liked this

Log in or join DZone for free to see who liked this article.

Log in Join for free
  • RSS
  • X
  • Facebook

ABOUT US

  • About DZone
  • Support and feedback
  • Community research

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • Become a Contributor
  • Core Program
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 3343 Perimeter Hill Drive
  • Suite 215
  • Nashville, TN 37211
  • [email protected]

Let's be friends:

  • RSS
  • X
  • Facebook