AngularJS with Bootstrap for Salesforce1 Mobile App Visualforce Page

AngularJS is a very popular JavaScript user interface (UI) libraries. It is used for data binding based on MVC pattern. If you need some CSS magic then I recommend using Bootstrap, a very popular CSS library.Blog on AngularJs - Boot Strap for VIsualforce

Let’s go through the set of steps with sample code for the implementation of AngularJS with Bootstrap on a Visualforce page.

Step 1: Create a new visualforce page

Setup (on top)> Develop (on left side menu)> Pages> new give page name in label field.

AngularJs-1

Step2: Add DocType=”html-5.0” under <apex:page> tag and include AngularJS and Bootstrap libraries

See below a complete sample code.

<apex:page docType=”html-5.0″>

<apex:stylesheet value=”//maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css”/>

<apex:includeScript value=”//ajax.googleapis.com/ajax/libs/angularjs/1.3.15/angular.min.js”/>

<script>

    angular.module(“ngApp”, []);

</script>

<style>

.box{width: 100%; margin:4% auto 0;}

.box input[type=text]{ padding: 10px 20px; border: solid 1px #ccc; font-size: 18px; color: #333;}

.box label{ font-size: 18px; color: #333;}

.box h1{ font-size: 18px; color: #333;}

</style>

<div class=”box” ng-app=”ngApp”>

<form>

        <label>Name:</label>

        <input type=”text” ng-model=”yourName” placeholder=”Enter a name here”/>

        <h1>Hello {{yourName}}!</h1>

    </form>

</div>

 </apex:page>

AngularJs-2

Once you are done with the code, click on the save button to save it. After that you can see the preview by clicking on the preview button this will show a page (screen shot attached) start writing a name into text box. This will show “Hello Amit” together. We have Salesforce Visulaforce working page, let’s go for Salesforce1 mobile App in the next step.

Step 3: Create new tab for Salesforce1 mobile App

Click on Create> Tabs in the left side menu this will take you on Custom Tabs page select Visualforce Tabs and click on New Button this will take you on New Visualforce Tab page there you can select Visualforce page name from the drop down menu, give the tab label name and click on Next button at the right side bottom, Now next window Add to Profiles will appear click on Next button there too this will take you on final window Add to Custom Apps  click on Save button.

AngularJs-3

The new tab will be visible on Visualforce Tabs page.

Step 4: Make your Visualforce page available for mobile

Go back on pages edit the “Hello” page you created, check the Check box “Available for Salesforce mobile apps”.

Step 5:  Optimize your mobile app

One last step for Salesforce1 mobile optimization go to Mobile Administration (left side menu)> Click on Mobile Navigation, Now Navigation Menu Items screen will be appear so add from available field into selected field and then click on Save button now you are ready to check in your mobile device. Type login.salesforce.com in your mobile browser and put your login credential, Click on top left side hamburger menu scroll down little bit see the “Test” tab you have created click on that now you are good to go on final output.

AngularJs-4AngularJs-6

Profile photo of Amit Tiwari

Amit Tiwari

I am a senior front end developer at Mirketa Inc. I love converting great UX designs into great web and mobile interfaces. Ping me if you want to talk about anything on front end UI development - Cross browser scripting, CSS, multi-device CSS, Visualforce, JS -- you get the point. :)
Posted in apex develeopment, Apex Development, HTML/CSS, Learn Salesforce, salesforce administrator, salesforce certified, salesforce consultant, salesforce development, salesforce Tips & Tricks, Salesforce1 Mobile app development, UI, UX, Visualforce.

Leave a Reply

Your email address will not be published. Required fields are marked *


one × = 7

CommentLuv badge
Skip to toolbar