2

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>

0

1 Answer 1

3

You need to define a controller.

Change:

<apex:page showHeader="true" sidebar="true">

to:

<apex:page controller="CaseDetailController" showHeader="true" sidebar="true">
0

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .