Search code examples
javascriptangularjsvisualforce

code did not enter script part


I'm trying to create a Salesforce VF Page. It is not entering the Script part, no console messages were printed in the console.

Please help.. I tried changing the position of script tag but nothing worked.

I tried debugging a lot but could not find any reason. I have removed most part of script as it dis not allow to save otherwise.

<apex:page sidebar="false" showHeader="false" controller="quote_details_controller">
    <head>
        <title>Quote Details</title>
        <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.3.15/angular.min.js">
        console.log('Hi');
        var app = angular.module("QuoteDetals",[]);
        app.factory("Quote_Details_Ctrl",quoteDetailsFactory);
        app.controller("Quote_Details_Ctrl",Quote_Details_Ctrl);
        function quoteDetailsFactory($q){
            var deferred = $q.defer();
            var loadData = function(quoteId){
                quote_details_controller.getQuote(quoteId,
                  function(result,event){
                    if(event.status){
                        deferred.resolve(angular.fromJson(result));
                    } else {
                        deferred.reject(event);
                    }
                  },
                  {escape:false}
                  );
                return deferred.promise;
            }
            return{ 
            loadData : loadData
            };
        }
        function Quote_Details_Ctrl($scope,Quote_Details_Ctrl){
            $scope.quoteData = [];
            $scope.quoteId = "{!$CurrentPage.parameters.quoteId}";
            console.log('quoteId : ' +quoteId);
            $scope.loadData = function(){
                var promise = quoteDetailsFactory.loadData($scope.quoteId);
                promise.then(function(obj){
                    $scope.quoteData = obj;
                },[]);
            console.log('quoteData : '+quoteData);
            }

        }
        window.onload = $scope.loadData(); 
    </script>
        <style>

        div.quote-detail-section-right{
        float:right;
        margin-top : 145px;
        margin-right: 80px;
        width:35%;
        }
    </style>
    </head>
    <body>
        <div class="quote-rec-page">
            <div class = "quote-details">
                <label for = "section" class="Segment">Quote Details</label>    
            </div>
            <div class ="btn-toolbar">
                <button type="button">Edit</button>
                <button type="button">Delete</button>
                <button type="button">Create PDF</button>
                <button type="button">Email Quote</button>
                <button type="button">Start Sync</button>
            </div>
            <form>
                <div class ="quote-detail-section-left">
                    <div>
                        <label for="quoteNum" class ="field-label">Quote Number</label>
                        <input type="text" class="quote-input"  tabindex="1" id="quoteNumber"/>
                    </div>
                    <div>
                        <label for="quoteName" class ="field-label">Quote Name</label>
                        <input type="text" class="quote-input"  tabindex="2" id="quoteName"/>
                    </div>
                    <div>
                        <label for="oppName" class ="field-label">Opportunity Name</label>
                        <input type="text" class="quote-input"  tabindex="3" id="oppName"/>
                    </div>
                    <div>
                        <label for="accName" class ="field-label">Account Name</label>
                        <input type="text" class="quote-input"  tabindex="4" id="accName"/>
                    </div>
                </div>
                <div class ="quote-detail-section-right">
                    <div>
                        <label for="expDate" class ="field-label">Expiration Date</label>
                        <input type="date" class="quote-input"  tabindex="5" id="expDate"/>
                    </div>
                    <div>
                        <label for="sync" class ="field-label">Syncing</label>
                        <input type="checkbox" class="quote-input"  tabindex="6" id="sync"/>
                    </div>
                    <div>
                        <label for="status" class ="field-label">Status</label>
                        <input type="text" class="quote-input"  tabindex="7" id="status"/>
                    </div>
                    <div>
                        <label for="quoteDesc" class ="field-label">Description</label>
                        <input type="text" class="quote-input"  tabindex="8" id="quoteDesc"/>
                    </div>
                </div>
            </form>
        </div>
    </body>
</apex:page>

Solution

  • If the src attribute is present, the <script> element must be empty. All of your javascript code must be contained in <script> tags that do not contain a src

    Replace

    <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.3.15/angular.min.js"> 
    

    With

    <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.3.15/angular.min.js"></script>
    <script>