Skip to main content
edited tags
Link
Adrian Larson
  • 151.3k
  • 38
  • 247
  • 431
Source Link
TemporaryFix
  • 3k
  • 6
  • 47
  • 93

Visualforce is not defined while using visual force remoting

I am using angular as a framework for this visualforce app, however when I try to use Visualforce remoting I get an error in the console

angular.min.js:123 ReferenceError: Visualforce is not defined

<apex:page showHeader="true" sidebar="true">
<head>
    <apex:stylesheet value="{!URLFOR($Resource.Bootstrap, 'bootstrap/css/bootstrap.min.css')}"/>
    <apex:stylesheet value="{!URLFOR($Resource.Bootstrap, 'bootstrap/css/bootstrap-theme.min.css')}"/>
    <apex:includeScript value="{!URLFOR($Resource.Jquery, 'jquery/jquery.js')}"/>
    <apex:includeScript value="{!URLFOR($Resource.Bootstrap, 'bootstrap/js/bootstrap.min.js')}"/>
    <apex:includeScript value="{!URLFOR($Resource.angular, 'angular/angular.min.js')}"/>
    <apex:includeScript value="/support/console/39.0/integration.js"/>
</head>
<body>
    <div ng-app="CaseDetail" ng-controller="CaseDetailController" class="bs">
        <div class="col-md-2">
        </div>
        <div class="col-md-8">
            <button ng-click="alertPage()">click</button>
        </div>
        <div class="col-md-2">
        </div>
    </div>
</body>
<script type="text/javascript">
    var app = angular.module('CaseDetail', []);
    app.controller('CaseDetailController', function ($scope) {
        $scope.alertPage = function() {
            Visualforce.remoting.Manager.invokeAction('CaseDetailController.getAlertMethod', '', function (response) {
                alert(response);
            });
        };
    });
</script>

</apex:page>