9

I've used Angular 1.x in Salesforce with quite a bit of success, but I was wondering if anyone has been able to work with Angular2.

I was able to get a very simple hello world to load, but only if I don't include the SF header (otherwise there seem to be script name-spacing conflicts).

I still don't know much about the framework in general, but it seems like there are a lot more dependancies (which may be an issue).

Just want to know if anyone out there has actually used Angular 2 in a real project and if so:

  • what does the basic configuration looks? (structure, dependancies, VF setup, etc)
  • what issues/concerns/challenges should be considered.
5

If you're still interested in creating an Angular 2 app on the Salesforce platform I may have a solution for you. I myself love Angular 2 and everything it brings to the table. My company also works exclusively on Salesforce, so I wanted to figure out a way to marry the two.

What I ended up doing was create a boilerplate to make it easier to get started with Angular 2 on Salesforce. The boilerplate itself is available on Github at https://github.com/iDev0urer/salesforce-angular2-boilerplate and allows you to develop your application locally using the REST and SOAP API's to manipulate data. It also provides an easy way to deploy your app to Salesforce using gulp deploy.

Please check it out and give me feedback!

  • Interesting... Does this run in a VF page when you deploy? – NSjonas Sep 7 '16 at 18:48
  • @NSjonas sure does! And it uses Visualforce Remoting too. – watzon Sep 7 '16 at 19:19
  • Ah I see now. I was looking for a VF page but didn't see one. But it looks like index.page.html somehow gets deployed as a VF page in the gulp deploy? – NSjonas Sep 7 '16 at 20:33
  • @NSjonas that is correct. It's a bit of templating magic that runs it as an html file locally, but transforms it into a Visualforce page when it's deployed – watzon Sep 8 '16 at 17:11
  • hi there - just checked out ur project. why would you want ppl to save their login data into the code? – Jörn Berkefeld Oct 25 '16 at 15:25
2

Working with Angular 2 is a bit different than usual angular 1. It's highly recommended you create your Angular 2 apps with Typescript. To run the apps in your VF ( or in any browser) you need to transpile it to Javascript othwerise your browser will not understand.

As you build your angular 2 app in modules you need a module bundler as well which will bundle your modules into a one single javascript file.

There are some good tools out there which will do that for you automatically. Have a look at Webpack module bundler ans see if its your requirements.

Have a look at these tutorials for a more detailed explanation. angular 2 tutorials using VF as a container

All the best

  • 2
    Tajinder Singh. Can you pls add your tutorial some part in this answer. because links may be expire later. – Ratan Paul Jun 3 '16 at 8:01

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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