0
AngularJS를 처음 사용했습니다. $ http 서비스를 사용하여 로컬 호스트에서 HTML 페이지를 요청하고 있습니다. 하지만 결과 대신 해당 페이지의 소스 코드가 나타납니다.
http_service.html 내가 myfile.html에 대신 소스 코드의 제목을 표시 할 수있는 방법
<!DOCTYPE html>
<html>
<head>
<title>AngularJs | HTTP Service</title>
<script src="js/angular.min.js"></script>
<script>
// Initialize the Angular Application
var app = angular.module('myApp', []);
// Initialize an Angular Controller
app.controller('controller', function($scope, $http){
// Ruquest a page from the remote server
$http.get('files/myFile.html')
// After initializing the $http object, run a succes function
.then(function(response){
$scope.reqData = response.config;
});
});
</script>
</head>
<body ng-app="myApp" ng-controller="controller">
<h4>{{reqData}}</h4>
</body>
</html>
파일/
<!DOCTYPE html>
<html>
<head>
<title>My file</title>
</head>
<body>
<h1>Hello from AngularJS by Google</h1>
</body>
</html>
myfile.html에.
@MohammedSiyab : 당신은 서버 측에서 HTML 파일을 렌더링하거나 그냥 바인딩 할 의미합니까 html로? –
클라이언트 측에서 파일을 채우려는 경우 ng-src를 사용하거나보기로도 플러그인 할 수 있습니다 –
HTML 페이지 대신 소스 코드를 의미합니까, HTML 소스 코드가 아닙니다. – maurycy