我正在尝试将结果从api GET打印到Sharepoint Online列表。当我单击页面上的按钮以运行代码时,结果将打印一秒钟,然后页面重新加载,我什么也看不到。请告诉我这段代码做错了什么。
var app = angular.module("ClinicManager", []);
var ClinicController = function ($scope, $http) {
var siteURL = "";
var onSuccess = function(response) {
$scope.clinics = response.data;
}
var onError = function(reason) {
$scope.error = "Could not find clinics";
}
$scope.search = function(storecode) {
$http.get(siteURL + "_api/web/lists/getbytitle('clinics')/items?$filter=Store_x0020_Code eq '" + storecode + "'")
.then(onSuccess, onError);
/*$http({
method: 'GET',
url: siteURL + "_api/web/lists/getbytitle('clinics')/items?$select=Title,ID$filter=Store_x0020_Code eq '" + storecode + "'",
headers: { "Accept": "application/json;odata=verbose" }
}).then(onSuccess, onError);*/
}
$scope.message = "Clinic Manager";
};
app.controller("ClinicController", ClinicController);
<div class="container" ng-app="ClinicManager">
<!--<div class="jumbotron">
<h1><span id="title">No Clinic Loaded!</span></h1>
<span id="address">No Clinic Loaded!</span>
</div>
<p></p>-->
<div ng-controller="ClinicController">
<h1>{{ message }}</h1>
<div>{{ error }}</div>
Storecode:
<input type="search" placeholder="Clinic to find" ng-model="storecode" />
<input type="submit" value="Search" ng-click="search(storecode)" />
<!--<table border=1>
<tr>
<th>ID</th>
<th>Title</th>
</tr>
<tr ng-repeat="clinic in clinics">
<td>{{ clinic.id }}</td>
<td>{{ clinic.title }}</td>
</tr>
</table>-->
{{ clinics }}
</div>
</div>