通过复数视频教程,我介绍了ng-include指令。但是,使用此指令我遇到了一些错误。 1. XMLHttpRequest无法加载 2.错误:无法在'XMLHttpRequest'上执行'send'
的index.html
<html ng-app="main">
<head>
<script src="angular.min.js"></script>
<script src="script.js"></script>
</head>
<body ng-controller="MainController">
<h1>{{message}}</h1>
<div>
{{error}}
</div>
<form name="searchUser" ng-submit="search(username)">
<input type="search" required placeholder="Username to find" ng-model="username"/>
<input type="submit" value="Search"/>
</form>
<div ng-include="'userdetails.html'" ng-show="user"></div>
</body>
</html>
userdetails.html
<div>
<h2>Name: {{user.name}}</h2>
<img ng-src="{{user.avatar_url}}" title="{{user.name}}"/>
<select ng-model="repoSortOrder">
<option value="+name">Name</option>
<option value="-stargazers_count">Stars</option>
<option value="+language">Language</option>
</select>
</div>
<table>
<thead>
<tr>
<th>Name</th>
<th>Stars</th>
<th>Language</th>
</tr>
</thead>
<tbody>
<tr ng-repeat="repo in repos | orderBy: repoSortOrder">
<td>{{repo.name}}</td>
<td>{{repo.stargazers_count | number}}</td>
<td>{{repo.language}}</td>
</tr>
</tbody>
</table>