SharePoint Online Webpart页面上的AngularJS错误

时间:2015-04-28 14:55:51

标签: javascript angularjs sharepoint

我有一个Web部件页面,其中添加了脚本编辑器Web部件。然后我将以下代码粘贴在......

    <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>

当我保存并查看该页面时,我只看到&#34; {{control.Title}}&#34;

当我在Chrome中检查控制台时,我看到一条错误消息,指出该模块无法加载...

  

未捕捉错误:[$ injector:modulerr]

我检查并重新检查了拼写。什么都行不通。我错过了什么?

1 个答案:

答案 0 :(得分:0)

您需要删除jQuery(document).ready(function () {才会运行您的代码,为什么它首先需要您。

Working Plunkr