1

I want to use Angular for a feature in Magento2 E-commerce website.

For Ex : - I want to create a page(MoodBoard) where customer can create a look using drag drop.

I have created a new module for it.

Now I need to implement Angular in this module.

How do I do that?

2
  • You are talking abt angular.js v.1? Commented Mar 13, 2020 at 6:49
  • I am working with AngularJS v1.7.9 but I don't mind if you give me solution related to another version
    – SharmaV
    Commented Mar 13, 2020 at 6:58

1 Answer 1

0

I have used Angular 1.6.6 in one of my custom builds.
you can follow this layout way to include the angularJs It will also add ng-app & ng-controller attributes to the body tag.

your_custom_layout.xml

<?xml version="1.0"?>
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
    <head>
        <link src="Custom_Module::js/angular.js"/> 
        <link src="Custom_Module::js/angular-filter.min.js"/> 
        <link src="Custom_Module::js/mycustom.js"/> 
    </head>
    <body>
        <!-- this will add an attribute to body class -->
        <attribute name='ng-app' value='myApp'/>
        <attribute name='ng-controller' value="myController" />
    </body>
</page> 

mycustom.js > In this file I have code for angular based logic.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.