<!DOCTYPE html>
<html>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.4.8/angular.min.js"></script>
<body>
<div ng-app="myApp" ng-controller="myCtrl">
<h1>{{myWelcome}}</h1>
</div>
<script>
var app = angular.module('myApp', []);
app.controller('myCtrl', function($scope, $http,Base64) {
$http.defaults.headers.common = {"Access-Control-Request-Headers": "accept, origin, authorization"};
$http.defaults.headers.common['Authorization'] = 'Basic ' + Base64.encode('admin' + ':' + 'admin');
$http({ method : "GET",
url : "http://10.132.32.212:8181/restconf/operational/network-topology:network-topology/",
Accept: "application/json",
withCredentials: true,
}).then(function mySucces(response) {
$scope.myWelcome = response.data;
}, function myError(response) {
$scope.myWelcome = response.statusText;
});
});
</script>
</body>
</html>
這是我的代碼,但我沒有得到任何響應數據。我在想,這是不是與URL驗證。我可以得到任何解決方案
是什麼反應?你有401狀態碼嗎? – mvermand
不,我沒有得到任何東西,它只顯示{{我的歡迎}}表達式 –
如果您實際在html頁面中看到「{{myWelcome}}」,那麼存在嚴重錯誤。檢查CONSOL錯誤 – mvermand