Skip to main content

Angular JS Installation Guide

Updated over a week ago

Widget Installation Guide for AngularJS (v1.x)

1. Add to index.html

Paste the following snippet before the closing </body> tag of your AngularJS app:
​

<!-- index.html -->
<!DOCTYPE html>
<html ng-app="myApp">
<head>
<meta charset="utf-8">
<title>My AngularJS App</title>
</head>
<body>
<div ng-view></div>

<!-- UserWay Widget -->
<script src="https://cdn.userway.org/widget.js" data-account="ACCOUNT-ID"></script>
</body>
</html>

Widget Installation Guide for Angular (v2+)

1. Add the script to index.html

In your src/index.html, insert the script right before the closing </body> tag:
​

<!-- src/index.html -->
<body>
<app-root></app-root>

<!-- UserWay Widget -->
<script src="https://cdn.userway.org/widget.js" data-account="ACCOUNT-ID"></script>
</body>

2. Optional: Dynamic Injection via Angular Component

If you want to load it dynamically (e.g., conditionally or after user interaction), use the following code in app.component.ts:
​

// src/app/app.component.ts
import { Component, OnInit, Renderer2 } from '@angular/core';

@Component({
selector: 'app-root',
templateUrl: './app.component.html'
})
export class AppComponent implements OnInit {
constructor(private renderer: Renderer2) {}

ngOnInit(): void {
const script = this.renderer.createElement('script');
script.src = 'https://cdn.userway.org/widget.js';
script.setAttribute('data-account', 'ACCOUNT-ID');
script.defer = true;
this.renderer.appendChild(document.body, script);
}
}

Remember to replace ACCOUNT-ID with your actual account id, which can be found at: https://userway.org/code

Did this answer your question?