11

Some time ago we used Angular 1.x on Visualforce pages for several apps. Now some of these Apps are aged and more or less in need of redesign. This redesign is not because of any actual shortcomings of Angular 1.x, but for other internal reasons and requirement changes.

This made me look closer on the current versions of Angular. Now there is Angular 4.x and the old version 1.x seems to be totally outdated...

They skipped Angular 3 and starting with Angular 2.x very fundamental design changes are introduced by the Angular developers, which makes it harder to use Angular by a simple <script> inclusion of one or many static resources like it was possible with Angular 1.x

Also the usage of TypeScript might be more difficult on Visualforce.

Searching the web, I came up with these links addressing Angular 2 - but this might still be valid and true even for Angular 4.x:

The concept in Chris W's answer here Feasability of Angular2 in Salesforce (through VF page) seems not very easy, since I would not like to develop locally and use REST and SOAP. Instead, I'm looking for a way to include some js-files (as done in good old Angular 1.x days) in a VF-page an write some pure JS for my app (not TS, no TypeScript). I did not dive into Angular 4.x deeply enough to see all implications and concepts yet. So this approach might be totally stupid - but I'd like to ask here before spending a long time research on Angular 4 concepts just to find out Visualforce and Angular 4 simply do not match at all...

Is there in the meantime any meaningful approach to use Angular 4 on Visualforce?

Has anyone found an meaningful usage of Angular 4 in Lightning Components? My assumption is, that it's not meaningful at all to combine Lightning Components with Angular 4 because the concepts do not match.

  • Maybe a starting point for lightning? github.com/forcedotcom/aura-ng - Disclaimer I do not do AJS so not sure if this is even helpful but thought I would at least throw it out there – Eric Apr 24 '17 at 18:09
  • @Eric this (github.com/forcedotcom/aura-ng) is all about Angular 1.3 - at this time everything was plain, simple and oldschool. But starting with 2.x the disruptive changes started. The fact that there was such a huge change became clear to me only last week. I'm pretty sure, that also other people here at SFSE are not totally aware of the enormous and possible non-compatible design-shifts of the Angular development. – Uwe Heim Apr 24 '17 at 18:15
  • Wow, using such an old version to work with lightning, who would thought. Like I said, AJS is a different world for me. Sorry it was not helpful. – Eric Apr 24 '17 at 18:19
  • Making Visualforce RemoteAction Bulletproof With TypeScript - salesforce.com/video/192909 Video from SF using TypeScript and VF - Again, not sure if it is that helpful but it is about typescript :) - But seems you need to compile the Typescript to JS then use the compiled JS in the VF page. Seems to add a dev step to the process – Eric Apr 24 '17 at 18:40
  • I think the above video (Watched a lot of it) may provide some good insights on how to use AngularJS 4 TS with VF. – Eric Apr 24 '17 at 19:19
1

On using Angular within Lightning Components, the real gotcha is mentioned at the end of Christophe Coenraets's blog post Creating Lightning Components with React and taken from the security Requirements Checklist):

Any Lightning package that uses Angular or React or other third party DOM-based templating frameworks will automatically fail the security review until such time as we provide custom lightning components to properly encapsulate these frameworks. This is to avoid template injection attacks resulting from double interpolation. In order to use another framework as part of a package that uses Lightning, please use an iframe or Visualforce container until approved Lightning containers are published.

On the feasibility, mixing a framework that manipulates the DOM (Angular) with a framework that injects a virtual DOM layer (Locker Service) to enforce security policy is not likely to end well (until Salesforce have the time/inclination to make them work together). As TypeScript is translated to JavaScript to run, I assume that language problem could be overcome by tweaking the tooling (or maybe existing tooling is already suitable).

With Angular 1 and Angular 2 being significantly different, going from Angular 1 to native Lightning Components instead might make sense.

| improve this answer | |
  • Thanks Keith, but leaving the security review aside, I would like to focus on the general feasibility of Angular 4.x - I think even on pure VF-pages it looks quite wrong to use Angular 4 - I mean at all. Unlike Angular 1.x - with that, the technical usage was plain, straightforward and simple. My question is focusing on the fundamental shift of Angular concepts and the (possibly mandatory?) use of TS (TypeScript) instead of JS for Angular 4. – Uwe Heim Apr 24 '17 at 18:26
  • @UweHeim Added a bit more to the answer on that. – Keith C Apr 24 '17 at 19:04
  • So we're in 2019 now. SalesForce seems to have added a special lightning component (Container) to allow React/Angular apps. Would this, right now, pass the security reviews? this is very important for my current project. – DARKGuy Jun 10 '19 at 0:29
  • @DARKGuy While my guess is "yes", best you e.g. book an office hours meeting with Salesforce and get confirmation (security.secure.force.com/sourcescanner). – Keith C Jun 10 '19 at 7:44

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