function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
bujjibujji 

Uncaught ReferenceError: angular is not defined at app:2

Hi Guys,

I am new bee to use angularjs in salesforce. Below is my code which is working fine when i put the below snippet in script tag in the same page.
var app = angular.module('myApp', []);
 app.controller('myctrl', function ($scope) {   
     <!--$scope.contacts = {!contacts} -->
     $scope.fname = 'Test1';
     $scope.lname = 'Test2';
 });

But when i put the above code in app.js static resource and refrenced <apex:includeScript value="{!$Resource.app}"/> it is throwing the error.
angular is not defined.

Could anybody tell me what is the wrong i am doing.

Thanks,
Bujji.
James BoggsJames Boggs
Have you added angular to your VF page as well?
bujjibujji
Yes.
James BoggsJames Boggs
May I see the VF page you're calling this script in?
bujjibujji

The name is :


My first expression: {{ 5 + 5 }}


First Name:


Last Name:

Full Name: {{fname+" "+lname}}


AngularJS Objects Name is: {{person.p1}} {{person.p2}}


AngularJS Array Animal Names are: First Animal is:{{animals[0]}} Second Animal is:{{animals[1]}}

{{x.name+', '+x.country}}


Thanks, Baji Shaik.
James BoggsJames Boggs

That isn't super helpful.

But the problem is that your script isn't finding angular.
You need to make sure that you're referencing angular on the page BEFORE your script:
 

<apex:page>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.3.14/angular.min.js">
<apex:includeScript value="{!$Resource.whatever}"/>
Your stuff here
</apex:page >