简体   繁体   中英

AngularJS Error on SharePoint Online Webpart Page

I have a web part page where I have added a Script Editor web part. I then pasted the following code in...

    <link data-require="bootstrap-css@*" data-semver="3.0.0" rel="stylesheet" href="//netdna.bootstrapcdn.com/bootstrap/3.0.0/css/bootstrap.min.css" />
<h2>Questionnaire:</h2>
<br />
<div ng-app="App">
    <div ng-controller="spListCtrl">
        <table width="100%" cellpadding="10" cellspacing="2" class="employee-table">
            <tr ng-repeat="control in Controls">
                <td>{{control.Title}}</td>
                <td>
                    <input type="radio" name="{{control.Id}}" value="Yes">Yes
                    <input type="radio" name="{{control.Id}}" value="No">No
                </td>
                <td>
                    <textarea id="{{control.Id}}Comment"></textarea>
                </td>
            </tr>
        </table>
    </div>
</div>
<script src="//code.jquery.com/jquery-1.11.2.min.js"></script>
<script src="//code.jquery.com/ui/1.11.4/jquery-ui.min.js"></script>
<script src="//ajax.googleapis.com/ajax/libs/angularjs/1.2.15/angular.min.js"></script>
<script>
    jQuery(document).ready(function () {
        var App = angular.module('App', [])
        .controller('spListCtrl', function ($scope, $http) {
            $http({
                method: 'GET',
                url: "https://myteamsite.domain.com/_api/web/lists/getByTitle('MyListName')/items?$select=Id,Title",
                headers: { "ACCEPT": "application/json;odata=verbose" }
            }).success(function (data, status, headers, config) {
                $scope.Controls = data.d.results;
            });
        });
    });
</script>

When I save and view the page, I just see "{{control.Title}}"

When I check the Console in Chrome, I see an error saying that the module couldn't be loaded...

Uncaught Error: [$injector:modulerr]

I have checked and rechecked the spelling. Nothing is working. What am I missing?

You need to remove jQuery(document).ready(function () { will run your code, why it needed you there in first place.

Working Plunkr

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM